聊天室-测试

聊天室测试

目前为 2025-03-02 提交的版本。查看 最新版本

// ==UserScript==
// @run-at       document-start
// @name         聊天室-测试
// @description  聊天室测试
// @namespace    fucker.space
// @version      0.0.1
// @author       chris
// @match        *://*/*
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @inject-into  content
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @require https://update.gf.qytechs.cn/scripts/528523/1545641/Chat_Room.js
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // 确保 jQuery 已加载
    if (typeof jQuery === 'undefined') {
        console.error('jQuery is required but not loaded!');
        return;
    }

    const chatRoom = new ChatRoom({
        wsServer: 'wss://topurl.cn:9001',
        maxHistory: 300
    });

    // 初始化聊天室
    const initChatRoom = () => {
        // 使用 MutationObserver 监听 DOM 变化
        const observer = new MutationObserver((mutations, obs) => {
            // 当 body 元素存在时初始化
            if (document.body) {
                obs.disconnect(); // 停止观察
                chatRoom.init();
            }
        });

        // 如果 body 已存在则直接初始化
        if (document.body) {
            chatRoom.init();
        } else {
            // 否则开始观察 DOM 变化
            observer.observe(document.documentElement, {
                childList: true,
                subtree: true
            });
        }
    };

    initChatRoom();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址