Async xmlhttprequest

封装 GM_xmlhttprequest

As of 11/07/2021. See the latest version.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/429203/949224/Async%20xmlhttprequest.js

// ==UserScript==
// @name         Async xmlhttprequest
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  封装 GM_xmlhttprequest
// @author       LinHQ
// @match        *
// @grant        GM_xmlhttprequest
// ==/UserScript==

(function() {
  'use strict';
  function req(details){
    return new Promise((res, rej) => {
      details.onload = res;
      details.ontimeout = rej;
      details.onabort = rej;
      details.onerror = rej;

      GM_xmlhttpRequest(
        details
      );
    });
  }
})();