您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Automatically redirects .org websites to their .com version if available
// ==UserScript== // @name Redirect .org to .com // @namespace http://tampermonkey.net/ // @version 1.0 // @description Automatically redirects .org websites to their .com version if available // @author Your Name // @match *://*.org/* // @grant none // ==/UserScript== (function() { 'use strict'; // List of .org sites you don't want to redirect const exceptions = [ 'wikipedia.org', 'archive.org', 'mozilla.org' ]; // Function to check if a site is an exception function isException(hostname) { return exceptions.some(exception => hostname.endsWith(exception)); } // Function to log redirection details function logRedirection(from, to) { console.log(`Redirecting from ${from} to ${to}`); } // Get the current hostname (e.g., 'example.org') const currentHost = window.location.hostname; // Check if it's an exception or already on .com if (currentHost.endsWith('.org') && !isException(currentHost)) { // Replace .org with .com const newHost = currentHost.replace('.org', '.com'); // Log redirection details logRedirection(currentHost, newHost); // Redirect to the new .com domain window.location.href = window.location.href.replace(currentHost, newHost); } else { // Log when no redirection occurs console.log(`No redirection for ${currentHost}`); } })();