TM_request

Tampermonkey http request 库

Tính đến 19-02-2021. Xem phiên bản mới nhất.

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @require https://update.greasyfork.org/scripts/418102/902218/TM_request.js

"use strict";function asyncGeneratorStep(t,e,n,r,o,u,a){try{var i=t[u](a);var s=i.value}catch(t){n(t);return}if(i.done){e(s)}else{Promise.resolve(s).then(r,o)}}function _asyncToGenerator(i){return function(){var t=this,a=arguments;return new Promise(function(e,n){var r=i.apply(t,a);function o(t){asyncGeneratorStep(r,e,n,o,u,"next",t)}function u(t){asyncGeneratorStep(r,e,n,o,u,"throw",t)}o(undefined)})}}function TM_request(r){var t;var o=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;r.retry=(t=r.retry)!==null&&t!==void 0?t:0;return new Promise(function(e,t){r.onload=r.onload||function(t){t.requestOptions=r;t.tmStatusText="Load";e(t)};r.ontimeout=r.ontimeout||function(t){t.requestOptions=r;t.tmStatusText="Timeout";e(t)};r.onerror=r.onerror||function(t){t.requestOptions=r;t.tmStatusText="Error";e(t)};r.onabort=r.onabort||function(t){t.requestOptions=r;t.tmStatusText="Abort";e(t)};GM_xmlhttpRequest(r)}).then(function(t){return t})["catch"](function(){var e=_asyncToGenerator(regeneratorRuntime.mark(function t(n){return regeneratorRuntime.wrap(function t(e){while(1){switch(e.prev=e.next){case 0:if(!(o>=r.retry)){e.next=5;break}console.error(n);throw n;case 5:e.next=7;return TM_request(r,++o);case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}},t)}));return function(t){return e.apply(this,arguments)}}())}