Skip to content

slymax/request-control

Repository files navigation

Request Control

This browser extension allows you to define rules for modifying, blocking, and redirecting web requests using a simple syntax that is close to natural language. The extension leverages chrome's declarativeNetRequest API for modifying network requests.

Installation

https://chrome.google.com/webstore/detail/request-control/gkadogdmakibilhnklflcgaennojgipd

Syntax

SET <URL_COMPONENT> VALUE <STRING> FOR URL <REGEX>
REMOVE <URL_COMPONENT> FROM URL <REGEX> -
REDIRECT URL <REGEX> TO URL <REGEX> -
BLOCK URL <REGEX> - - -
ALLOW URL <REGEX> - - -

<URL_COMPONENT> can be FRAGMENT, HOST, PASSWORD, PATH, PORT, QUERY, SCHEME, or USERNAME.

Examples

SET QUERY ?⁠useskin=vector FOR https://en.wikipedia.org/wiki
REMOVE FRAGMENT FROM https://en.wikipedia.org/wiki/URL#Syntax -
REDIRECT https://(.*?).m.wikipedia.org TO https://$1.wikipedia.org -
BLOCK https://www.reddit.com - - -
ALLOW https://www.reddit.com/r/popular - - -

FAQs

Why are my redirects not working?

Some websites install service workers that intercept network requests before they can be processed by the browser. You can unregister service workers either via DevTools (Application > Service Workers) or by pasting the following code into the address bar of an affected website (you'll have to retype the javascript: part after pasting):

javascript:navigator.serviceWorker.getRegistrations().then(rs => { for (const r of rs) r.unregister() });

The extension automatically unregisters service workers when rules for popular websites are applied (see config.js for the full list of websites).

Why is my regular expression not working? I'm getting an error that the regexFilter is invalid.

Chrome uses google's re2 for evaluating regular expressions. Expressions containing lookarounds are not supported.

Development

To grab the latest version of monaco-editor, run the following command:

curl -Lso monaco.js https://esm.run/monaco-editor

Roadmap