Async xmlhttprequest

封装 GM_xmlhttprequest

当前为 2021-07-11 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/429203/949224/Async%20xmlhttprequest.js

  1. // ==UserScript==
  2. // @name Async xmlhttprequest
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.1
  5. // @description 封装 GM_xmlhttprequest
  6. // @author LinHQ
  7. // @match *
  8. // @grant GM_xmlhttprequest
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. function req(details){
  14. return new Promise((res, rej) => {
  15. details.onload = res;
  16. details.ontimeout = rej;
  17. details.onabort = rej;
  18. details.onerror = rej;
  19.  
  20. GM_xmlhttpRequest(
  21. details
  22. );
  23. });
  24. }
  25. })();