Greasy Fork is available in English.

GM Fetch

A fetch API of GM_xmlhttpRequest

이 스크립트는 직접 설치해서 쓰는 게 아닙니다. 다른 스크립트가 메타 명령 // @require https://update.greasyfork.org/scripts/472236/1249646/GM%20Fetch.js(으)로 포함하여 쓰는 라이브러리입니다.

개발자
Secant
버전
1.2.0
생성
2023-08-02
갱신
2023-09-13
라이선스
MIT

@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):

// @require   https://cdn.jsdelivr.net/npm/@sec-ant/gm-fetch@latest/dist/index.iife.js

Usage

  1. Grant necessary GM_APIs:

    vite-plugin-monkey:

    {
      plugins: [
        monkey({
          userscript: {
            // or GM.xmlHttpRequest
            grant: "GM_xmlhttpRequest",
            // whatever websites you're to make requests to
            connect: ["github.com"],
          },
        }),
      ];
    }
    

    plain userscript:

    // @grant     GM_xmlhttpRequest
    // @connect   github.com
    
  2. 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:

    /* globals gmFetch */
    (function () {
      "use strict";
      gmFetch("https://github.com/Sec-ant/gm-fetch");
    })();
    

License

MIT