您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Detects and stops nefarious URL redirections allows redirects on trusted websites and logs the actions
当前为
// ==UserScript== // @name Stop Nefarious Redirects // @namespace http://tampermonkey.net/ // @version 2.4 // @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 = [ '500px.com', 'adobe.com', 'adobe.com', 'amazon.com', 'apple.com', 'arstechnica.com', 'artstation.com', 'asana.com', 'atlassian.com', 'axios.com', 'battle.net', 'bbc.com', 'behance.net', 'bestbuy.com', 'blogger.com', 'booking.com', 'buzzfeed.com', 'canva.com', 'cnn.com', 'codecademy.com', 'constantcontact.com', 'coursera.org', 'deviantart.com', 'discord.com', 'docusign.com', 'dribbble.com', 'dropbox.com', 'duolingo.com', 'ebay.com', 'edx.org', 'engadget.com', 'epicgames.com', 'etsy.com', 'eurogamer.net', 'facebook.com', 'figma.com', 'flickr.com', 'forbes.com', 'framer.com', 'freecodecamp.org', 'gamespot.com', 'gettyimages.com', 'github.com', 'gizmodo.com', 'gog.com', 'hubspot.com', 'huffpost.com', 'humblebundle.com', 'ign.com', 'ikea.com', 'imdb.com', 'imgur.com', 'instagram.com', 'intuit.com', 'invisionapp.com', 'itch.io', 'khanacademy.org', 'kotaku.com', 'lifehacker.com', 'linkedin.com', 'lynda.com', 'mailchimp.com', 'mashable.com', 'masterclass.com', 'medium.com', 'microsoft.com', 'mozilla.org', 'msn.com', 'netflix.com', 'nytimes.com', 'origin.com', 'paypal.com', 'pcgamer.com', 'pexels.com', 'pinterest.com', 'pixabay.com', 'pluralsight.com', 'polygon.com', 'quora.com', 'reddit.com', 'salesforce.com', 'samsung.com', 'shutterstock.com', 'sketch.com', 'skillshare.com', 'skype.com', 'slack.com', 'soundcloud.com', 'spotify.com', 'stackoverflow.com', 'steamcommunity.com', 'surveymonkey.com', 'target.com', 'techcrunch.com', 'theguardian.com', 'theverge.com', 'tiktok.com', 'trello.com', 'tripadvisor.com', 'tumblr.com', 'twitch.tv', 'twitter.com', 'udemy.com', 'unsplash.com', 'Vice.com', 'vimeo.com', 'vk.com', 'vox.com', 'walmart.com', 'washingtonpost.com', 'whatsapp.com', 'wikimedia.org', 'wikipedia.org', 'wired.com', 'wordpress.com', 'wsj.com', 'yahoo.com', 'yelp.com', 'youtube.com', 'zapier.com', 'zendesk.com', 'zeplin.io', 'zoom.us', 'google.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(); })();