Nefarious URL Redirect Blocker

Detects and stops URL redirections, loads the original URL, and logs the actions

目前為 2024-04-09 提交的版本,檢視 最新版本

作者
slyfox1186
評價
0 0 0
版本
1.8
建立日期
2024-04-09
更新日期
2024-04-09
尺寸
2.1 KB
授權條款
MIT
腳本執行於
所有網站

Stop Redirects - A Tampermonkey Script

Description

Stop Redirects is a Tampermonkey script that detects and stops URL redirections, ensuring that you stay on the original URL and avoid being redirected to unintended websites. It provides a seamless browsing experience by preventing unwanted redirects and keeping you on the webpage you initially visited.

Features

  • Detects and stops URL redirections in real-time
  • Loads the original URL when a redirect is detected
  • Works in both forward and backward navigation scenarios
  • Logs actions in the browser console for debugging purposes
  • Easy to install and use with Tampermonkey browser extension

How It Works

The Stop Redirects script utilizes JavaScript to monitor URL changes and intercept redirection attempts. Here's a breakdown of how the script functions:

  1. The script starts by storing the original URL of the webpage you are currently on.

  2. It sets up event listeners for the beforeunload and popstate events, which are triggered when a page is about to be unloaded or when the browser history changes (e.g., when navigating forward or backward).

  3. The script continuously checks for URL changes by comparing the current URL with the stored original URL.

  4. If a URL change is detected and the script has not already been activated, it means a redirection attempt has been made.

  5. The script then takes the following actions:

    • It stops the redirection by preventing the default behavior of the event and stopping event propagation.
    • It pushes the original URL into the browser history using window.history.pushState(), creating a new history entry.
    • It replaces the current URL displayed in the browser's address bar with the original URL using window.history.replaceState().
    • It logs the action in the browser console, indicating that a redirection has been stopped and the original URL has been loaded.
  6. The script resets its activation flag and schedules the next check for URL changes after a short delay (100 milliseconds).

  7. This process continues, enabling the script to continuously monitor and prevent redirections throughout your browsing session.

Installation and Usage

To use the Stop Redirects script, follow these steps:

  1. Install the Tampermonkey browser extension in your preferred web browser (e.g., Chrome, Firefox).

  2. Open the Tampermonkey dashboard and click on the "+" button to create a new script.

  3. Copy and paste the entire code of the Stop Redirects script into the Tampermonkey editor.

  4. Customize the @match directives in the script header to specify the websites or URL patterns where you want the script to be active. By default, it matches all HTTP and HTTPS URLs.

  5. Save the script in Tampermonkey.

  6. The script will now be active and will automatically detect and stop redirects on the specified websites.

  7. To view the script's actions and logs, open the browser console (usually by pressing F12 or right-clicking and selecting "Inspect" > "Console").

That's it! With the Stop Redirects script installed and active, you can browse the web without worrying about unwanted redirects. The script will silently work in the background, ensuring that you stay on the original URLs you visit.

QingJ © 2025

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