Stop Nefarious Redirects

Detects and stops nefarious URL redirections, allows redirects on trusted websites, and logs the actions

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

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

Nefarious URL Redirect Blocker - A Tampermonkey Script

Description

Nefarious URL Redirect Blocker 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. The script allows redirects on trusted websites specified in the trustedWebsites list.

Features

  • Detects and stops URL redirections in real-time
  • Allows redirects on trusted websites specified in the trustedWebsites list
  • Loads the original URL when a nefarious 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 Nefarious URL Redirect Blocker 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 checks if the current website is listed in the trustedWebsites list. If it is a trusted website, the script allows the redirect and updates the current and previous URLs accordingly.

  6. If the website is not trusted, the script 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 nefarious redirection has been stopped and the original URL has been loaded.
  7. The script resets its activation flag and schedules the next check for URL changes after a short delay (100 milliseconds).

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

Installation and Usage

To use the Nefarious URL Redirect Blocker 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 Nefarious 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. Modify the trustedWebsites list in the script to include the websites or domains where you want to allow redirects. You can add or remove websites as needed.

  6. Save the script in Tampermonkey.

  7. The script will now be active and will automatically detect and stop nefarious redirects on the specified websites while allowing redirects on trusted websites.

  8. 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 Nefarious URL Redirect Blocker script installed and active, you can browse the web with enhanced security against nefarious redirections. The script will silently work in the background, ensuring that you stay on trusted URLs and are protected from unwanted redirects.

QingJ © 2025

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