@sec-ant/gm-fetch
A fetch API for GM_xmlhttpRequest / GM.xmlHttpRequest.
Features
- Use
responseType: stream to prevent buffering large data when possible.
- Use Typescript.
- Provides es module, iife script and lib mode userscript as well.
Install
If you use vite-plugin-monkey:
npm i @sec-ant/gm-fetch
or just plain userscript (change latest to the version number as needed):
Usage
-
Grant necessary GM_APIs:
vite-plugin-monkey:
{
plugins: [
monkey({
userscript: {
grant: "GM_xmlhttpRequest",
connect: ["github.com"],
},
}),
];
}
plain userscript:
-
Use it just like fetch:
vite-plugin-monkey:
import gmFetch from "@sec-ant/gm-fetch";
gmFetch("https://github.com/Sec-ant/gm-fetch");
plain userscript:
(function () {
"use strict";
gmFetch("https://github.com/Sec-ant/gm-fetch");
})();
License
MIT