VRCW.net World ID to VRCX Deeplink

Converts VRChat world IDs to VRCX deeplinks on vrcw.net

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         VRCW.net World ID to VRCX Deeplink
// @namespace    au.benjithatfoxguy.vrcw.net
// @icon         https://cdn.benjifox.gay/favicon.ico
// @version      1.2.3
// @description  Converts VRChat world IDs to VRCX deeplinks on vrcw.net
// @author       BenjiThatFoxGuy
// @match        *://*.vrcw.net/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const worldIdRegex = /wrld_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;

    function processTextNode(node) {
        const text = node.textContent;
        if (worldIdRegex.test(text)) {
            const span = document.createElement('span');
            span.innerHTML = text.replace(worldIdRegex, match => 
                `<a href="vrcx://world/${match}" style="color: inherit; text-decoration: underline;">${match}</a>`
            );
            node.parentNode.replaceChild(span, node);
        }
    }

    function findAndReplaceWorldIds(root) {
        const walker = document.createTreeWalker(
            root,
            NodeFilter.SHOW_TEXT,
            {
                acceptNode: function(node) {
                    return worldIdRegex.test(node.textContent) ? 
                        NodeFilter.FILTER_ACCEPT : 
                        NodeFilter.FILTER_REJECT;
                }
            }
        );

        const nodes = [];
        while (walker.nextNode()) nodes.push(walker.currentNode);
        nodes.forEach(processTextNode);
    }

    // Process existing content
    findAndReplaceWorldIds(document.body);

    // Watch for dynamic content changes
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(node => {
                if (node.nodeType === Node.ELEMENT_NODE) {
                    findAndReplaceWorldIds(node);
                }
            });
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });
})();