Skip to content

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

License

Notifications You must be signed in to change notification settings

DAFF0D11/hard-redirect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Topics

Resources

License

Stars

Watchers

Forks