Stop Nefarious Redirects

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

Versión del día 09/04/2024. Echa un vistazo a la versión más reciente.

Autor
slyfox1186
Calificaciones
0 0 0
Versión
2.4
Creado
09/04/2024
Actualizado
09/04/2024
Tamaño
5.89 KB
Licencia
MIT
Funciona en
Todos los sitios

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.

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 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 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 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 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 Nefarious URL Redirect Blocker 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.