Greasy Fork

Greasy Fork is available in English.

bilinovel

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

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

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

(function() {
  'use strict';

  const AD_TIPS_SELECTOR = '.adblock-tips'; // 反广告拦截脚本添加的提示框的选择器
  const CONTENT_ID = 'acontent'; // 被反广告拦截脚本隐藏的内容区域的 ID
  const MAX_ATTEMPTS = 10; // 增加尝试次数,确保覆盖原始脚本的多次执行
  const CHECK_INTERVAL = 500; // 缩短检查间隔,更快地响应原始脚本的操作

  let attempts = 0;
  let cleanupInterval = null;

  function performCleanup() {
      attempts++;
      // console.log(`[Anti-Anti-Adblock] 第 ${attempts} 次尝试清理...`); // 可以取消注释用于调试

      let needsFurtherChecks = false; // 标记是否还需要继续检查

      // 1. 隐藏提示信息 (不再移除)
      const adBlockTips = document.querySelector(AD_TIPS_SELECTOR);
      if (adBlockTips && adBlockTips.style.display !== 'none') {
          console.log("[Anti-Anti-Adblock] 发现广告拦截提示,强制隐藏:", adBlockTips);
          adBlockTips.style.setProperty('display', 'none', 'important');
          needsFurtherChecks = true; // 原始脚本可能会尝试再次显示它
      } else if (adBlockTips) {
          // 提示框存在但已经是隐藏的,可能不需要再做什么,但原始脚本可能还在运行
          needsFurtherChecks = true;
      }

      // 2. 恢复内容区域
      const contentArea = document.getElementById(CONTENT_ID);
      if (contentArea && contentArea.style.display === 'none') {
          console.log("[Anti-Anti-Adblock] 发现被隐藏的内容区域,尝试恢复显示:", contentArea);
          contentArea.style.display = ''; // 恢复默认显示状态
          needsFurtherChecks = true; // 原始脚本可能会尝试再次隐藏它

          // 2.1 移除 "诱饵" div 的逻辑保持不变 (仍然注释掉,除非需要)
          /*
          const potentialBait = contentArea.lastElementChild;
          if (potentialBait && potentialBait.tagName === 'DIV' && potentialBait.classList.length > 0) {
               console.log("[Anti-Anti-Adblock] 尝试移除内容区域内最后一个可能是诱饵的 DIV:", potentialBait);
               // potentialBait.remove();
          }
          */
      } else if (contentArea && contentArea.style.display !== 'none') {
           // 内容区域可见,可能不需要再做什么,但原始脚本可能还在运行
           needsFurtherChecks = true;
      }


      // 3. 停止检查逻辑
      // 如果达到了最大尝试次数,或者连续几次检查都没有发现需要修改的地方
      // (这里简化为达到最大次数就停止)
      if (attempts >= MAX_ATTEMPTS) {
          console.log("[Anti-Anti-Adblock] 已达到最大尝试次数,停止主动检查。错误可能仍然会偶尔出现,但页面功能应已恢复。");
          if (cleanupInterval) clearInterval(cleanupInterval);
      } else if (!needsFurtherChecks && attempts > 2) {
          // 如果连续几次检查都没发现问题,也可能提前停止 (可选逻辑)
          // console.log("[Anti-Anti-Adblock] 连续检查未发现问题,暂时停止检查。");
          // if (cleanupInterval) clearInterval(cleanupInterval);
      }
  }

  // 立即执行一次清理,尝试在原始脚本第一次运行前或运行时进行干预
  performCleanup();

  // 继续使用 setInterval 定期检查,以应对原始脚本的重复执行
  cleanupInterval = setInterval(performCleanup, CHECK_INTERVAL);

})();