Greasy Fork

Greasy Fork is available in English.

贴吧奇怪域名重定向

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

当前为 2024-07-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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    http://greasyfork.icu/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;
        }
    }
})();