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

declarativenetrequest

v1.0.1

Published

Firefox extension that modifies HTTP headers and GET parameters, blocks requests and redirects them to HTTPS by your own rules.

Readme

declarativeNetRequest

Firefox extension that modifies HTTP headers and GET parameters, blocks requests and redirects them to HTTPS by your own rules. The browser applies the rules itself through its declarativeNetRequest API, without a request listener.

The overview in the sidebar: the rules that target the page, their buttons and the event log

Changes in 1.0.1

Since 1.0.0:

  • Blocked parts of the page — below a blocking rule, the popup and the sidebar list the domains of the page's requests the rule blocked since the page loaded (for example scripts from gstatic.com on calendar.google.com), each with buttons that suspend the rule for that domain for an hour or add the domain to the rule's Except domains. A rule that no longer targets the page (the page is in its Except domains) is listed too while it still blocks parts of it, such as the files of an embedded frame from another domain. It needs the permission to follow requests (webRequest): Settings → "Allow listing blocked parts of pages".
  • Except bookmark folder — a rule can skip the sites bookmarked in a folder (also in its subfolders): with "except the whole domain of the folder's bookmarks" (the default) their whole domains, as if they were in the Except domains; without it only the bookmarked addresses, and only out of the rule's own addresses.
  • Watch changes in the bookmark folder — a new option of each bookmark folder of a rule (the folder it targets and its Except folder). On, a bookmark added, changed or removed in the folder changes the rules right away — the way 1.0.0 always worked, and rules from 1.0.0 keep it. Off, the rule keeps the bookmarks the folder had when the rule was last saved or when the browser started.
  • Filter by MIME type — a new kind of rule that acts on responses by their Content-Type header (image/*, application/pdf, ready-made groups of types, "Except" types, responses without Content-Type): it blocks them, redirects them to another address or to empty content (an empty image, script, stylesheet, …), or modifies their headers with ready-made modifications (download instead of showing, show as plain text, disallow scripts, don't cache, accept no cookies, …). Firefox does not support conditions on response headers yet: the editor offers these rules and says so on their card, but the extension does not send them to Firefox (one such rule would make it reject all the rules). It checks the support at each start, so saved rules of this kind apply once Firefox supports them.
  • Dashboard — the overview can also be shown on a whole page (dashboard.html): Settings → "Show module output" → "Dashboard". When the overview is no longer in the popup, the toolbar button opens the dashboard.
  • With AnalyticExtension — the "Block domain" and "Block service worker" buttons of the app details of PWA Info in AnalyticExtension add the domain of an app and the script of its service worker to rules of this extension (see With AnalyticExtension). They need this version; with 1.0.0 AnalyticExtension says the version cannot do this blocking yet.
  • Smaller changes — the toolbar and sidebar icon follows the light or dark look of the browser, and Settings show the version of each module.

What it does

Rules are edited in Settings. Each rule says:

  • what to do — modify request or response headers, remove or set GET parameters, block the requests, redirect them from HTTP to HTTPS, or filter responses by their MIME type (the Content-Type header — e.g. image/*, application/pdf, with "Except" types and optionally responses without Content-Type): block them, redirect them to another address (also to empty content such as an empty image or script), or modify their headers with ready-made modifications (download instead of showing, show as plain text, disallow scripts, sandbox, don't cache, accept no cookies, …) and your own response-header edits. Firefox does not support response-header conditions yet: the editor offers these rules and says so on their card, but this extension does not send them to Firefox (one such rule would make it reject all the rules); they work where the module runs in Chrome 128 and later;
  • where — domains, addresses (* stands for anything) or the bookmarks of a bookmark folder, with "Except" domains and an "Except" bookmark folder; with "Watch changes in the bookmark folder" (on by default) a bookmark added, changed or removed in the folder changes the rules right away, without it the rule keeps the bookmarks the folder had when the rule was last changed and saved, or when the browser started;
  • which requests — the page, frames, scripts, styles, images, fonts, fetch/XHR, media, WebSocket, others.

The toolbar popup and the sidebar show the rules that target the page of the active tab. There you can suspend a rule for an hour (everywhere, or only for the domain of the page), add the domain to its "Except" domains, see the parts of the page a blocking rule blocked, block the domain or the address of the page, and read the event log of the rules that keep one.

The extension comes with a set of default rules. Some are turned on (removing tracking GET parameters, blocking dangerous CDN servers, removing a few Facebook parameters, and sending two privacy-preference headers); others are ready to turn on. Review them in Settings after granting the permission below — they can affect how sites work, and the uncommon headers may make your browser easier to identify.

Using the extension

First-time setup

After installation, the extension opens a welcome page with a short guide:

The welcome page

  1. Click the extension's toolbar button and open Settings (or open about:addons, select declarativeNetRequest, then Preferences).
  2. In the Declarative Net Request section, click Allow request modification and approve access to all websites. Without this permission, the browser cannot apply the rules.
  3. Review the rules in Settings. The enabled defaults remove common tracking parameters, block requests to a list of known dangerous CDN domains, remove a few unnecessary parameters on Facebook, send a Global Privacy Control signal, and send a cookie preference for functional-only cookies. These two headers are uncommon and may make your browser easier to identify. An HTTP-to-HTTPS rule is also available but disabled by default. You can enable, disable, or edit rules to suit your needs.

While browsing

Click the toolbar button to see rules that target the current page. From the popup (or the extension's sidebar), you can:

  • Suspend a rule for one hour, either everywhere or only for the current domain. Use this to check whether a rule is causing a site problem; it will resume automatically.
  • Add the current domain to a rule's Except list. This keeps the exception until you remove it in Settings.
  • Open Blocked parts of the page below a blocking rule: the domains of the page's requests the rule blocked since the page loaded (for example scripts from gstatic.com on calendar.google.com), each with the same buttons — suspend the rule for that domain for an hour, or add the domain to the rule's Except list. A rule that no longer targets the page (the page is in its Except list) is listed too while it still blocks parts of it, such as the files of an embedded frame from another domain. This needs the permission to follow requests (webRequest, Settings → "Allow listing blocked parts of pages"); the browser does not say which rule blocked a request, so the overview infers it.
  • Block the current domain or the exact page address. The block is added to a rule in Settings and stays in effect until you remove it there.
  • Open the event log, when available. It is not a complete record of every rule match: Firefox reports blocked requests and HTTP-to-HTTPS redirects, but does not identify every rule it applies.

If a site stops working, first suspend a suspected rule for an hour. If that fixes the site, add a domain exception or adjust the rule in Settings rather than turning off protections you still want on other sites.

The toolbar popup with the rules that target the page

The sidebar shows the same overview with more room:

The overview in the sidebar

Creating and managing rules

In Settings, add or edit a rule by choosing its action (change request or response headers, remove or set URL parameters, block requests, or redirect HTTP to HTTPS), its target (domains, URL patterns, or a bookmark folder), and the request types it should affect. Use Except domains when a rule should skip a site, or Except bookmark folder to skip the sites bookmarked in a folder (with "except the whole domain", the default, their whole domains; without it only the bookmarked addresses, and only out of the rule's own addresses — the browser cannot except a single address from a domain or a * pattern). Each folder has its own Watch changes in the bookmark folder: leave it on when the folder is a list you keep updating, turn it off when the rule should stay with the bookmarks it has. Start with a narrow target and test one change at a time: blocking or changing requests can affect how a website works.

The rule editor in Settings

Each rule is a card in the editor; its Details hold what it does, which requests and where, and Show the rule in JSON lists the declarativeNetRequest rules the browser gets from it:

A rule with its details open in the editor

The toolbar popup is for quick actions on the current page; Settings is where rules are reviewed and maintained. The sidebar shows the same page overview with more room.

Everyday Use: A Practical Guide

Check What Applies to a Page

Open the extension popup while viewing a website. It lists the rules that target that page and shows whether a rule is active or temporarily suspended. If no rules are listed, the page may simply have no matching rules. Browser-internal pages, such as extension settings, are not ordinary web pages and cannot be modified by these rules.

Test a Rule Before Keeping a Change

  1. In the popup, suspend a suspected rule for one hour, either everywhere or only for the current domain.
  2. Reload the page and check whether the problem is gone. Rules affect new requests; they do not undo requests that have already loaded.
  3. If the rule caused the problem, add the domain to that rule's Except list to keep the rule active on other websites, or edit the rule in Settings.

A temporary suspension ends automatically after one hour. An exception is permanent until you remove it in the rule editor.

Choose the Right Scope

A domain target covers requests to that domain and its subdomains, as well as files loaded by its pages from other domains. An address target is narrower: it affects requests to the matching page or file, but does not cover other files that page loads from elsewhere. Use a domain when you mean a whole site; use an address when you mean one specific page or file.

The popup's block actions have different effects too. Block domain blocks requests to the domain and its subdomains across websites. Block this address blocks only the exact page address. Both actions add an entry to a rule in Settings, where you can later change or remove it.

Know What the Defaults Send

Along with removing tracking parameters and blocking a list of dangerous CDN domains, the enabled defaults remove a few Facebook parameters and send two request headers: Sec-GPC: 1 (a Global Privacy Control signal) and Cookie-Preference: functional. These headers express preferences, but they are uncommon and may make your browser easier to identify. Review or disable them in Settings if you do not want to send them. The HTTP-to-HTTPS rule is available but starts disabled.

Understand the Event Log

The event log is not a full browsing history or a complete list of every rule match. In Firefox, it can show blocked requests and requests redirected to HTTPS; Firefox does not report every applied rule. A rule must also be set to write events to the log, and the required browser permission must be granted. Use the rule overview to see which rules target the current page.

Permissions

Rules do not apply until you grant access to all pages: Settings → "Allow request modification". The popup and the sidebar say so while it is missing.

| Permission | Granted | What for | | --- | --- | --- | | declarativeNetRequestWithHostAccess | at installation | the rules in the browser | | storage, alarms | at installation | the rules and settings; the end of a temporary suspension | | activeTab | at installation | the address of the active tab for the overview | | <all_urls> | on request | the browser applies the rules only to addresses the extension has access to | | bookmarks | on request | rules that target or except a bookmark folder | | notifications, webRequest | on request | notifications about applied rules, the event log and the blocked parts of pages | | declarativeNetRequestFeedback | on request | the browser's own report of applied rules (Firefox does not implement it) | | scripting | on request | the floating window of the core |

Firefox does not report which rule was applied. The notifications and the event log therefore cover only blocked requests and requests redirected to HTTPS, found out through webRequest.

The module itself sends nothing off the device (data_collection_permissions: none).

With AnalyticExtension

The extension works on its own. When AnalyticExtension is installed too, this extension offers it its overview and rule editor. Once you allow that in the Settings of AnalyticExtension ("Modules from other extensions"), AnalyticExtension shows them in its popup, sidebar and Settings, its "Block the image permanently" button of Image Info adds images to the rules here, and the "Block domain" and "Block service worker" buttons of the app details of PWA Info add the domain of an app and the script of its service worker to the rules "PWA info sandbox - blocked domains" and "PWA info sandbox - blocked service workers" here. The rules, the permissions and the work stay with this extension.

Rules stored in the module of AnalyticExtension are not taken over. To keep them, back up the module in Import/Export of AnalyticExtension before allowing this extension and restore the backup afterwards — it then lands here.

Development

Load the extension from about:debugging#/runtime/this-firefox → "Load Temporary Add-on…" → manifest.json.

Requires Node.js 22 or newer. The project has no dependencies; npm install only turns on the git hook.

npm install   # once: git then runs the tests before each commit (.githooks/pre-commit)
npm test      # the tests in tests/ (node:test)

The tests also run on GitHub (.github/workflows/test.yml) and before npm publish.

Release

The version is in package.json and manifest.json and the tests check that both are the same. Change it with npm version, which updates both, commits and tags:

npm version patch   # or minor, major, X.Y.Z — Firefox accepts numbers only, no "-beta.1"
git push --follow-tags
npm publish

License

CC BY-SA 4.0