https://github.com/sec-ant/gm-fetch
A fetch API for GM_xmlhttpRequest.
https://github.com/sec-ant/gm-fetch
fetch gm-fetch gm-xmlhttprequest greasemonkey tampermonkey userscript violentmonkey
Last synced: 11 months ago
JSON representation
A fetch API for GM_xmlhttpRequest.
- Host: GitHub
- URL: https://github.com/sec-ant/gm-fetch
- Owner: Sec-ant
- License: mit
- Created: 2023-08-02T05:03:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-23T22:06:32.000Z (over 1 year ago)
- Last Synced: 2025-03-25T20:15:32.477Z (12 months ago)
- Topics: fetch, gm-fetch, gm-xmlhttprequest, greasemonkey, tampermonkey, userscript, violentmonkey
- Language: TypeScript
- Homepage: https://fastly.jsdelivr.net/npm/@sec-ant/gm-fetch@latest/dist/
- Size: 742 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# @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](https://github.com/lisonge/vite-plugin-monkey):
```bash
npm i @sec-ant/gm-fetch
```
or just plain userscript (change `latest` to the version number as needed):
```js
// @require https://cdn.jsdelivr.net/npm/@sec-ant/gm-fetch@latest/dist/index.iife.js
```
## Usage
1. Grant necessary GM_APIs:
vite-plugin-monkey:
```ts
{
plugins: [
monkey({
userscript: {
// or GM.xmlHttpRequest
grant: "GM_xmlhttpRequest",
// whatever websites you're to make requests to
connect: ["github.com"],
},
}),
];
}
```
plain userscript:
```js
// @grant GM_xmlhttpRequest
// @connect github.com
```
2. Use it just like fetch:
vite-plugin-monkey:
```ts
import gmFetch from "@sec-ant/gm-fetch";
gmFetch("https://github.com/Sec-ant/gm-fetch");
```
plain userscript:
```js
/* globals gmFetch */
(function () {
"use strict";
gmFetch("https://github.com/Sec-ant/gm-fetch");
})();
```
## License
MIT