Greasy Fork

Greasy Fork is available in English.

bilinovel

去除bilinovel检测到屏蔽后隐藏内容

目前为 2025-04-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         bilinovel
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  去除bilinovel检测到屏蔽后隐藏内容
// @author       karl
// @match        https://www.bilinovel.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=bilinovel.com
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';

    // 选择所有同时具有 'adv-box' 和 'contente' 类的元素
    // 注意选择器 '.adv-box.contente' 会精确匹配同时拥有这两个类的元素
    const elementsToModify = document.querySelectorAll('.adv-box.contente');

    if (elementsToModify.length > 0) {
        elementsToModify.forEach(element => {
            // 从元素的类列表中移除 'adv-box' 类
            element.classList.remove('adv-box');
        });
    }

    // --- 可选:处理动态加载的内容 ---
    // 如果页面内容是动态加载的(例如通过 AJAX),上面的代码可能在元素出现前就执行了。
    // 可以使用 MutationObserver 来监视 DOM 变化。
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.addedNodes) {
                mutation.addedNodes.forEach(node => {
                    // 检查新添加的节点本身是否匹配
                    if (node.nodeType === 1 && node.matches('.adv-box.contente')) {
                        console.log('猴油脚本 (Observer):发现新添加的匹配元素,移除 adv-box 类。');
                        node.classList.remove('adv-box');
                    }
                    // 检查新添加的节点内部是否包含匹配的元素
                    if (node.nodeType === 1) { // 确保是元素节点
                        const newElements = node.querySelectorAll('.adv-box.contente');
                        if (newElements.length > 0) {
                             console.log(`猴油脚本 (Observer):发现 ${newElements.length} 个新元素内部的匹配项,移除 adv-box 类。`);
                             newElements.forEach(el => el.classList.remove('adv-box'));
                        }
                    }
                });
            }
        });
    });

    // 配置观察器:观察整个文档的子节点变化和子树变化
    observer.observe(document.body || document.documentElement, {
        childList: true,
        subtree: true
    });

})();