Nefarious URL Redirect Blocker

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

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

// ==UserScript==
// @name         Nefarious URL Redirect Blocker
// @namespace    http://tampermonkey.net/
// @version      2.2
// @description  Detects and stops nefarious URL redirections, allows redirects on trusted websites, and logs the actions
// @match        http://*/*
// @match        https://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // List of trusted websites or domains where redirects are allowed
    const trustedWebsites = [
        'google.com',
        'youtube.com',
        'facebook.com',
        'amazon.com',
        'wikipedia.org',
        'twitter.com',
        'instagram.com',
        'linkedin.com',
        'apple.com',
        'microsoft.com',
        'netflix.com',
        'reddit.com',
        'imgur.com',
        'ebay.com',
        'twitch.tv',
        'pinterest.com',
        'spotify.com',
        'github.com',
        'stackoverflow.com',
        'dropbox.com',
        'vimeo.com',
        'imdb.com',
        'yahoo.com',
        'paypal.com',
        'wordpress.com',
        'tumblr.com',
        'adobe.com',
        'soundcloud.com',
        'nytimes.com',
        'bbc.com',
        'cnn.com',
        'theguardian.com',
        'yelp.com',
        'etsy.com',
        'wikimedia.org',
        'vk.com',
        'blogger.com',
        'msn.com',
        'quora.com',
        'skype.com',
        'whatsapp.com',
        'walmart.com',
        'target.com',
        'bestbuy.com',
        'ikea.com',
        'booking.com',
        'tripadvisor.com',
        'mozilla.org',
        'trello.com',
        'zoom.us',
        'discord.com',
        'tiktok.com',
        'samsung.com',
        'medium.com',
        'forbes.com',
        'huffpost.com',
        'washingtonpost.com',
        'wsj.com',
        'techcrunch.com',
        'buzzfeed.com',
        'Vice.com',
        'vox.com',
        'axios.com',
        'mashable.com',
        'wired.com',
        'theverge.com',
        'gizmodo.com',
        'engadget.com',
        'lifehacker.com',
        'arstechnica.com',
        'gamespot.com',
        'ign.com',
        'polygon.com',
        'kotaku.com',
        'pcgamer.com',
        'eurogamer.net',
        'steamcommunity.com',
        'epicgames.com',
        'origin.com',
        'battle.net',
        'gog.com',
        'humblebundle.com',
        'itch.io',
        'udemy.com',
        'coursera.org',
        'edx.org',
        'khanacademy.org',
        'duolingo.com',
        'codecademy.com',
        'freecodecamp.org',
        'pluralsight.com',
        'skillshare.com',
        'lynda.com',
        'masterclass.com',
        'zendesk.com',
        'atlassian.com',
        'salesforce.com',
        'hubspot.com',
        'intuit.com',
        'zapier.com',
        'asana.com',
        'slack.com',
        'docusign.com',
        'surveymonkey.com',
        'mailchimp.com',
        'constantcontact.com',
        'canva.com',
        'figma.com',
        'invisionapp.com',
        'adobe.com',
        'sketch.com',
        'framer.com',
        'zeplin.io',
        'behance.net',
        'dribbble.com',
        'artstation.com',
        'deviantart.com',
        '500px.com',
        'flickr.com',
        'shutterstock.com',
        'gettyimages.com',
        'unsplash.com',
        'pexels.com',
        'pixabay.com'
        // Add more trusted websites or domains here
    ];

    // Store the original URL
    const originalUrl = window.location.href;

    // Flag to track if the script has been activated
    let scriptActivated = false;

    // Function to log actions
    function logAction(message) {
        console.log(message);
    }

    // Function to check if a website is trusted
    function isTrustedWebsite(url) {
        return trustedWebsites.some(website => url.includes(website));
    }

    // Function to handle redirection
    function handleRedirect(event) {
        // Check if the URL has changed
        if (window.location.href !== originalUrl && !scriptActivated) {
            // Check if the current website is trusted
            if (isTrustedWebsite(window.location.href)) {
                // Allow the redirect on trusted websites
                return;
            }

            // Set the script activation flag
            scriptActivated = true;

            // Stop the redirection
            event.preventDefault();
            event.stopPropagation();

            // Log the action
            logAction('Nefarious redirection stopped.');
        }
    }

    // Function to continuously check for URL changes
    function checkUrlChange() {
        if (window.location.href !== originalUrl && !scriptActivated) {
            // Check if the current website is trusted
            if (isTrustedWebsite(window.location.href)) {
                // Allow the redirect on trusted websites
                return;
            }

            // Set the script activation flag
            scriptActivated = true;

            // Push the original URL into the browser history
            window.history.pushState(null, null, originalUrl);

            // Replace the current URL with the original URL
            window.history.replaceState(null, null, originalUrl);

            // Log the action
            logAction('Nefarious redirection stopped. Original URL loaded.');
        }

        // Reset the script activation flag
        scriptActivated = false;

        // Schedule the next check
        setTimeout(checkUrlChange, 100);
    }

    // Listen for the beforeunload event (forward direction)
    window.addEventListener('beforeunload', handleRedirect);

    // Listen for the popstate event (backward direction)
    window.addEventListener('popstate', handleRedirect);

    // Start checking for URL changes
    checkUrlChange();
})();

QingJ © 2025

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