Archon链接汉化

将archon.gg页面中wowhead链接转换为中文版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Archon链接汉化
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  将archon.gg页面中wowhead链接转换为中文版本
// @author       DeepSeek
// @match        https://www.archon.gg/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=archon.gg
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // 修改链接的核心函数
    function convertToCN(originalUrl) {
        return originalUrl.replace(
            /^(https?:\/\/www\.wowhead\.com)(?!\/cn)/,
            '$1/cn'
        );
    }

    // 处理所有存在的链接
    function updateLinks() {
        const wowheadLinks = document.querySelectorAll('a[href*="wowhead.com"]');

        wowheadLinks.forEach(link => {
            const originalHref = link.href;
            const newHref = convertToCN(originalHref);

            if (originalHref !== newHref) {
                link.href = newHref;

                // 移除跳转中间页面(可选)
                if (link.search.includes('?') && !link.search.includes('cn')) {
                    link.search = link.search.replace('?', '?cn&');
                }
            }
        });
    }

    // 初始化执行 + 动态内容监听
    updateLinks();
    new MutationObserver(updateLinks).observe(document.body, {
        childList: true,
        subtree: true
    });
})();