OVERHEAD

Block JavaScript only for subdomains in uBlock Origin

WHAT!?

Here’s an example scenario to demonstrate:

  • JavaScript is globally disabled.
  • For the “neocities.org” domain, you want JS to be enabled.
  • But for subdomains under “neocities.org”, you still want JS to be disabled.

First, go to uBlock Origin’s settings page, navigate to My rules, and set the following:

Example uBlock Origin dynamic filters which globally disables JS, but re-enables JS just for “neocities.org” (and all it’s subdomains).

no-scripting: * true
no-scripting: neocities.org false

Then, navigate to My filters and set the following:

Example uBlock Origin static filters which disables both external and inline JS for subdomains under “neocities.org” (but not “neocities.org” itself).

||*.neocities.org^$script
||*.neocities.org^$inline-script

Static filter lines prefixed with ! can be used for comments (e.g. ! Disable JS for subdomains under neocities.org, but not neocities.org itself).

It may be possible to combine the two static filters into one line, but given how difficult it was to even find out how to do this? Yeah, I have no clue what that’d look like.

To test if the filters are working correctly, navigate to your browser’s developer tools, typically bound to F12, and find the page responsible for monitoring network requests (In Firefox, it’s simply the tab labelled Network). All GET requests for .js files should appear to be unsuccessful, possibly with a message like Blocked by uBlock Origin for each blocked request.

You can’t rely on the appearance of the “</>” symbol in uBlock Origin’s extension to determine if everything is working, since it only indicates the status of the no-scripting rule as set by dynamic filters, not static filters.