Greasy Fork

Greasy Fork is available in English.

bilinovel

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

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

// ==UserScript==
// @name         bilinovel
// @namespace    http://tampermonkey.net/
// @version      1.9
// @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
  // 更新:选择器,用于定位在标题和内容之间的动态生成的 DIV,并确保它不是内容区本身
  const DYNAMIC_AD_DIV_SELECTOR = '#apage > .atitle + div:not([id="acontent"])';
  const MAX_ATTEMPTS = 10;
  const CHECK_INTERVAL = 500;

  let attempts = 0;
  let cleanupInterval = null;

  function performCleanup() {
      attempts++;
      let needsFurtherChecks = false;

      // 1. 隐藏提示信息
      const adBlockTips = document.querySelector(AD_TIPS_SELECTOR);
      if (adBlockTips && adBlockTips.style.display !== 'none') {
          adBlockTips.style.display = 'none';
          needsFurtherChecks = true;
      } else if (adBlockTips) {
          needsFurtherChecks = true;
      }

      // 2. 恢复内容区域
      const contentArea = document.getElementById(CONTENT_ID);
      if (contentArea && contentArea.style.display === 'none') {
          contentArea.style.display = '';
          needsFurtherChecks = true;
      } else if (contentArea) {
           needsFurtherChecks = true;
      }

      // 3. 隐藏动态生成的广告位 (使用更新后的选择器)
      const dynamicAdDiv = document.querySelector(DYNAMIC_AD_DIV_SELECTOR);
      if (dynamicAdDiv && dynamicAdDiv.style.display !== 'none') {
          dynamicAdDiv.setAttribute('style', 'display: none !important');
          needsFurtherChecks = true;
      } else if (dynamicAdDiv) {
           needsFurtherChecks = true;
      }

      // 4. 停止检查逻辑
      if (attempts >= MAX_ATTEMPTS) {
          if (cleanupInterval) clearInterval(cleanupInterval);
      }
  }

  // 立即执行一次清理
  performCleanup();

  // 继续使用 setInterval 定期检查
  cleanupInterval = setInterval(performCleanup, CHECK_INTERVAL);

})();