贴吧奇怪域名重定向

把一些奇怪的域名重定向到tieba.baidu.com

目前为 2024-07-30 提交的版本。查看 最新版本

// ==UserScript==
// @name         贴吧奇怪域名重定向
// @version      0.4.2
// @description  把一些奇怪的域名重定向到tieba.baidu.com
// @author       rteta
// @match        *://nba.baidu.com/*
// @match        *://c.tieba.baidu.com/*
// @match        *://tiebac.baidu.com/*
// @match        *://www.tieba.com/*
// @match        *://fexclick.baidu.com/*
// @match        *://youhua.baidu.com/*
// @match        *://ala.baidu.com/*
// @match        *://static.tieba.baidu.com/*
// @match        *://nani.baidu.com/*
// @grant        none
// @license      MIT
// @namespace    https://greasyfork.org/users/1217761
// ==/UserScript==
//(0.4.1以前GLM4编写,以后是GPT4o优化)
(function() {
    'use strict';

    // 获取当前页面的URL
    var currentURL = window.location.href;

    // 定义需要重定向的域名(使用正则表达式以支持http和https)
    var domainsToRedirect = [
        /^https?:\/\/nba\.baidu\.com/,
        /^https?:\/\/nani\.baidu\.com/,
        /^https?:\/\/c\.tieba\.baidu\.com/,
        /^https?:\/\/tiebac\.baidu\.com/,
        /^https?:\/\/www\.tieba\.com/,
        /^https?:\/\/youhua\.baidu\.com/,
        /^https?:\/\/ala\.baidu\.com/,
        /^https?:\/\/static\.tieba\.baidu\.com/,
        /^https?:\/\/fexclick\.baidu\.com/
    ];

    // 目标URL
    var targetURL = "https://tieba.baidu.com";

    // 检查当前URL是否匹配需要重定向的域名
    for (var i = 0; i < domainsToRedirect.length; i++) {
        if (domainsToRedirect[i].test(currentURL)) {
            // 将页面重定向到目标URL
            window.location.href = currentURL.replace(domainsToRedirect[i], targetURL);
            break;
        }
    }
})();