您需要先安装一个扩展,例如 篡改猴、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.78.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 = [ '500px.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(`[Stop Nefarious Redirects] ${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 current website is trusted if (isTrustedWebsite(window.location.href)) { // Allow the redirect on trusted websites return; } if (!scriptActivated) { // Set the script activation flag scriptActivated = true; // Log the redirection details logAction(`Redirection detected:`); logAction(`Original URL: ${originalUrl}`); logAction(`Attempted Redirect URL: ${window.location.href}`); logAction(`Redirection Method: ${event.type}`); // Stop the redirection event.preventDefault(); event.stopPropagation(); // Disable all inputs that can cause redirection disableInputs(); // Load the original URL after a 100ms delay setTimeout(function() { window.location.href = originalUrl; logAction(`Original URL loaded: ${originalUrl}`); }, 100); } } // Function to disable all inputs that can cause redirection function disableInputs() { // Disable clicks document.addEventListener('click', function(event) { event.preventDefault(); event.stopPropagation(); }, true); // Disable form submissions document.addEventListener('submit', function(event) { event.preventDefault(); event.stopPropagation(); }, true); // Disable keypresses document.addEventListener('keypress', function(event) { event.preventDefault(); event.stopPropagation(); }, true); // Disable touch events document.addEventListener('touchstart', function(event) { event.preventDefault(); event.stopPropagation(); }, true); logAction('All inputs disabled.'); } // Listen for the popstate event (backward direction) window.addEventListener('popstate', handleRedirect); // Listen for the hashchange event window.addEventListener('hashchange', handleRedirect); // Start monitoring for redirects logAction(`Script started. Original URL: ${originalUrl}`); })();