DAFF0D11 / hard-redirect

A simple browser extension to redirect urls defined by *you* in the source code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Hard Redirect

A simple browser extension to redirect urls defined by you in the source code.

Features

  • Regex defined url matching.
  • Enable/Disable redirects in popup menu.

How to add redirects

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.

Regex matching

This random google support answer describes the syntax quite well.
https://support.google.com/a/answer/1371415?hl=en

Install

  1. Navigate to: chrome://extensions/
  2. Toggle “Developer mode” in the top right.
  3. Click “Load unpacked” and select the hard-redirect directory

Firefox

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…

Twitter uses service workers which do not play nicely with DNR.

Workarounds:

  1. Directly changing the url with a content script when on twitter.com. Better described in this superuser question.
  2. Disable all javascript for twitter. No javascript = no service workers = no problems. Just remember to delete the existing service worker if there is one.

About

A simple browser extension to redirect urls defined by *you* in the source code.

License:GNU General Public License v3.0


Languages

Language:JavaScript 94.2%Language:HTML 5.8%