A simple browser extension to redirect urls defined by you in the source code.
- Regex defined url matching.
- Enable/Disable redirects in popup menu.
Redirects are defined at the top of background.js.
let redirectList = [
{ id: 1, label: "google -> startpage", from: "https://www.google.com/(.*)", to: "https://www.startpage.com/\\1", enabled: false },
{ id: 2, label: "youtube -> piped", from: "(.*)youtube.com/(.*)", to: "https://piped.kavin.rocks/\\2", enabled: true },
{ id: 3, label: "reddit -> libreddit", from: "(.*)reddit.com(.*)", to: "https://libredd.it/\\2", enabled: true },
]
Redirects are comprised of:
id: sequential number to identify individual redirects.
label: how the redirect is shown in the popup menu for enabling/disabling redirects.
from: pattern to redirect.
to: result of redirection.
enabled: the default state of the redirect.
This random google support answer describes the syntax quite well.
https://support.google.com/a/answer/1371415?hl=en
- Navigate to: chrome://extensions/
- Toggle “Developer mode” in the top right.
- Click “Load unpacked” and select the hard-redirect directory
Firefox(nightly.101.0a1) does not implement Manifest v3.
Hard Redirect uses Declarative Net Request (DNR) which is very different from the manifest v2 chrome.webRequest.
Twitter uses service workers which do not play nicely with DNR.
Workarounds:
- Directly changing the url with a content script when on twitter.com. Better described in this superuser question.
- Disable all javascript for twitter. No javascript = no service workers = no problems. Just remember to delete the existing service worker if there is one.