npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sec-ant/gm-fetch

v1.2.6

Published

A fetch API for GM_xmlhttpRequest / GM.xmlHttpRequest

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:

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");
    })();

The default credentials: "same-origin" sends cookies only when the request URL has the same origin as the current page. Use credentials: "include" for cross-origin requests that need cookies, or credentials: "omit" to disable cookies. Redirect handling follows the userscript manager's cookie policy.

Requests can be cancelled with an AbortSignal, including while preparing an upload or consuming a response body. Uploads are buffered because the GM APIs accept buffered request data. Streaming downloads are used when the GM API exposes RESPONSE_TYPE_STREAM; other environments use a Blob response.

Userscript managers

Both Manifest V2 and Manifest V3 managers work through their GM request APIs. The following extensions were checked with a local HTTP server on 2026-10-24:

| Manager | Browser | Manifest | Verified API | | -------------------- | -------------------------- | -------- | ---------------------------------------- | | Tampermonkey 5.5.1 | Chromium 156 | V3 | GM_xmlhttpRequest, GM.xmlHttpRequest | | Tampermonkey 5.5.0 | Firefox 157 | V2 | GM.xmlHttpRequest | | Violentmonkey 2.49.0 | Chromium 156 / Firefox 157 | V3 / V2 | Both APIs | | ScriptCat 1.5.0 | Chromium 156 | V3 | Both APIs | | Greasemonkey 4.14 | Firefox 157 | V2 | GM.xmlHttpRequest |

Checks cover text and binary uploads, empty responses, cloned redirects, cookie policies, and cancellation. Violentmonkey and ScriptCat use the Blob fallback. Greasemonkey uploads use binary strings because its request details are serialized as JSON. Its API has no abort handle, so cancellation rejects the fetch call while the manager's network request can continue.

Promise-only APIs and the responseURL response shape also have regression coverage for managers such as FireMonkey and Safari Userscripts; those extensions have not been tested directly. Header modification, redirects, cache options, and cookies during redirects follow the manager's implementation. Grant the appropriate GM API and @connect hosts, and enable user scripts in the browser when required by an MV3 manager.

Development

pnpm install --frozen-lockfile
pnpm exec playwright install chromium firefox
pnpm test
pnpm coverage
pnpm type-check
pnpm build

Tests run in Chromium and Firefox with simulated GM callbacks. Type checking covers the library, build configuration, and tests.

License

MIT