This script redirects user-specified URLs to new ones, by replacing part of the URL.
How to Use
- Install with your extension of choice (Tampermonkey, Greasemonkey, etc.)
- In the script settings, add the sites you want to affect to either the user includes or user matches.
- Navigate to one of your included/matched sites - this script should be active, and you should see a Configure redirect settings option. If not, something is wrong with your user includes/matches.
- Click the Configure redirect settings option to show the config pane. See the Settings section below for how to use it.
- After saving your settings, redirection should be active - navigate to a matching page to test it.
Settings
This script works by replacing pieces of the URL.
Simple
Each line in the Targets field will be replaced by the same line in the Replacements field.
For example, consider these settings:
Targets |
Replacements |
In |
Out |
Up |
Down |
With these settings, we would redirect as follows:
Advanced
A URL-wide find/replace can be too much - it's very easy to replace something you don't want.
For example, say you want to redirect from company.com/phone to company.com/call. You might use these settings:
Targets |
Replacements |
action |
do |
phone |
call |
That mostly works, but there's an issue:
Page |
Redirects To |
Notes |
company.com/phone |
company.com/call |
|
company.com/action/getinfo |
company.com/do/getinfo |
|
company.com/action/find-my-phone |
company.com/do/find-my-call |
<-- We didn't want to replace phone here! |
Option 1: Make targets more specific
One way to get around this is add more text to the start and/or end of the targets (and since we want to keep that text, also add it to their replacements).
For example, we might add company.com/ to the start to make sure we only replace our desired bit:
Targets |
Replacements |
company.com/action |
company.com/do |
company.com/phone |
company.com/call |
This works fine, but it's clunky when we're adding the same text to the start/end of every target and replacement.
Option 2: Prefix/Suffix options
If you're always adding the same text to the start/end of your targets (and replacements), you can instead use the Prefix and Suffix options.
Any text in these fields is added to the start/end of every target and replacement, so you don't have to add it manually.
So for our example above, we could instead use:
Prefix = company.com/
Targets |
Replacements |
action |
do |
phone |
call |
Changelog
- 1.0 (5/11/20)
- 1.1 (3/17/21)
- Make URL matching case-insensitive
- 2.0 (5/29/25): Major rewrite!
- Added a proper settings page using GM_Config:
- No more messing around with JSON in extension/script storage!
- The settings page can be launched from any included/matched site - look for the "Configure redirect settings" option under your extension (Tampermonkey, Greasemonkey, etc.) menu.
- Added support for different settings per site (previously all sites used the same settings).
Source: GitHub. Please direct all issues/questions there.
Available on Greasy Fork镜像 for easy installation.