Greasy Fork镜像 还支持 简体中文。

URL Replacer/Redirector

Redirect specific sites by replacing part of the URL.

作者
Gavin Borg
今日安裝
0
安裝總數
1,090
評價
3 0 0
版本
2.0
建立日期
2020-05-11
更新日期
2025-05-29
尺寸
11.0 KB
授權條款
未知
腳本執行於

This script redirects user-specified URLs to new ones, by replacing part of the URL.


How to Use

  1. Install with your extension of choice (Tampermonkey, Greasemonkey, etc.)
  2. In the script settings, add the sites you want to affect to either the user includes or user matches.
  3. 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.
  4. Click the Configure redirect settings option to show the config pane. See the Settings section below for how to use it.
  5. 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:

Page Redirects To Notes
https://www.google.com/In/query https://www.google.com/Out/query
https://www.google.com/IN/query https://www.google.com/Out/query We ignore case when matching (replacements match config casing)
https://www.google.com/IN/query/Up/in/blog https://www.google.com/Out/query/Down/Out/blog All matches are replaced (including multiple of same target)

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)
    • Initial release
  • 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.

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址