bilibili-Ignored

屏蔽正在观看人数、弹幕数量。Detect specific HTML code and comment it out.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         bilibili-Ignored
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  屏蔽正在观看人数、弹幕数量。Detect specific HTML code and comment it out.
// @author       You
// @match        *://*.bilibili.com/*
// @grant        none
// @license MIT
// ==/UserScript==

// 使用 MutationObserver 观察 DOM 变化
const observer = new MutationObserver(() => {
    // 找到父级目标元素
    let parentTarget = document.querySelector('.bpx-player-sending-bar .bpx-player-video-info');

    if (parentTarget) {
        // 定义要注释掉的三个子元素的选择器
        const classes = [
            '.bpx-player-video-info-online',
            '.bpx-player-video-info-divide',
            '.bpx-player-video-info-dm'
        ];

        // 遍历每个选择器并注释掉相应的元素
        classes.forEach(function(className) {
            let element = parentTarget.querySelector(className);

            if (element) {
                let comment = document.createComment(element.outerHTML);
                element.replaceWith(comment);  // 用注释替换元素
            }
        });

        observer.disconnect();  // 找到后停止观察
    }
});

// 开始观察文档中的变化
observer.observe(document, { childList: true, subtree: true });