Skip to content

ggabarrin/noscript-tag-blocker

Repository files navigation

icon noscript-tag-blocker

A Firefox WebExtension for blocking <noscript> tags.


Note: This extension is built using the WebExtensions API for cross-browser compatibility. However, it uses the webRequest.filterResponseData() function, which is currently only supported by Firefox.

Build

  1. Clone this repository
git clone https://github.com/ggabarrin/noscript-tag-blocker.git
  1. Install dependencies
yarn install --dev
  1. Build!

This command will create the zip file you need to install in the browser

yarn build
  1. A zip file should have been created in the noscript-tag-blocker/dist directory

Deploy

In order to permanently install in Firefox, please follow these steps:

  1. Open Firefox
  2. Go to about:config and set the xpinstall.signatures.required key to false (this will allow you to install unsigned extensions)
  3. Go to about:addons, click on the ⚙️ icon, and click on Install Add-on From File... option
  4. In case you are building the plugin yourself, select the built zip file, which is located by default in the noscript-tag-blocker/dist directory. If not, you may download an already built zip file from the Releases page.
  5. You should see the extension's icon in your browser's toolbar

Test

The following command allows you to install temporarily the browser plugin on Firefox for testing.

yarn test

How does it work?

This extension uses the webRequest.filterResponseData() function, which allows to modify the HTTP responses before they are rendered by the browser.

Specifically, it replaces the tags with hidden <textarea> tags, avoiding the alternate content to be displayed.

Browser without noscript-tag-blocker

<noscript>
  <p>This is a test</p>
</noscript>

Browser with noscript-tag-blocker

<textarea style="display: none !important;" noscript-tag-blocker="">
    &lt;p&gt;This is a test&lt;/p&gt;
</textarea>

Acknowledgments

This project is based on Mozilla Developer Network's http-response WebExtensions example.