A fetch API of GM_xmlhttpRequest
目前為
此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/472236/1229114/GM%20Fetch.js
A fetch API of GM_xmlhttpRequest.
responseType: stream to prevent buffering large data when possible.If you use vite-plugin-monkey:
npm i @sec-ant/gm-fetch
or just plain userscript (change the version number as needed):
// @require https://cdn.jsdelivr.net/npm/@sec-ant/[email protected]/dist/index.umd.js
Grant necessary GM_APIs:
vite-plugin-monkey:
{
plugins: [
monkey({
userscript: {
grant: "GM_xmlhttpRequest",
// whatever websites you're to make requests to
connect: ["localhost"],
},
}),
];
}
plain userscript:
// @grant GM_xmlhttpRequest
// @connect localhost
Use it just like fetch:
vite-plugin-monkey:
import gmFetch from "@sec-ant/gm-fetch";
gmFetch("http://localhost:4567/100.zip");
plain userscript:
/* globals gmFetch */
(function () {
"use strict";
gmFetch("http://localhost:4567/100.zip");
})();
MIT