Async xmlhttpRequest

封装 GM_xmlhttpRequest

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://greasyfork.org/scripts/429203-async-xmlhttprequest/code/Async%20xmlhttpRequest.js?version=949231

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

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

    GM_xmlhttpRequest(
      details
    );
  });
}