AWBW Viewer Count Hider

Hides viewer count

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AWBW Viewer Count Hider
// @namespace    https://awbw.amarriner.com/
// @version      1.0
// @description  Hides viewer count
// @icon         https://awbw.amarriner.com/favicon.ico
// @author       lol
// @match        https://awbw.amarriner.com/game.php?games_id=*
// @grant        none
// @license       MIT
// ==/UserScript==

(function () {
    'use strict';

    function hideViewerCount(node) {
        const viewer = node.querySelector('.game-viewer-count');
        if (viewer) {
            const cover = document.createElement('span');
            cover.textContent = '???';
            cover.style.fontWeight = 'bold';
            cover.style.color = '#000';
            node.replaceWith(cover);
        }
    }

    document.querySelectorAll('span.small_text_14.bold').forEach(hideViewerCount);

    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            for (const node of mutation.addedNodes) {
                if (node.nodeType === 1) {
                    if (node.matches && node.matches('span.small_text_14.bold')) {
                        hideViewerCount(node);
                    } else if (node.querySelector) {
                        const match = node.querySelector('span.small_text_14.bold');
                        if (match) hideViewerCount(match);
                    }
                }
            }
        }
    });

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