Greasy Fork

Greasy Fork is available in English.

删除刺猬猫打开弹幕

检测并删除页面上的打开弹幕

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         删除刺猬猫打开弹幕
// @namespace    http://tampermonkey.net/
// @version      2024-10-02
// @description  检测并删除页面上的打开弹幕
// @author       muyuanjin
// @match        https://www.ciweimao.com/chapter/*
// @grant        none
// @run-at       document-end
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    /**
     * 删除指定的弹幕盒子
     */
    function removeBarrageBox() {
        const barrageBox = document.getElementById('J_BarrageBox');
        if (barrageBox) {
            barrageBox.remove();
            console.log('已删除弹幕盒子');
        }
    }

    // 初始检查
    removeBarrageBox();

    // 使用MutationObserver监视DOM变化
    const observer = new MutationObserver((mutations) => {
        for (let mutation of mutations) {
            if (mutation.type === 'childList') {
                // 检查新添加的节点中是否包含弹幕盒子
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === 1) { // 元素节点
                        if (node.id === 'J_BarrageBox' || node.querySelector('#J_BarrageBox')) {
                            removeBarrageBox();
                        }
                    }
                });
            }
        }
    });

    // 配置观察选项
    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

})();