69shuba Ad Filtering

2025/6/26 15:24:19

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        69shuba Ad Filtering
// @namespace   Violentmonkey Scripts
// @match       https://www.69shuba.com/*
// @grant       none
// @version     1.3
// @author      -
// @description 2025/6/26 15:24:19
// @license     GPL-3.0
// ==/UserScript==

(function() {
    'use strict';

    let tmp = document.getElementById('txtright');
    if(tmp){
      tmp.style.display = 'none';
    }

    tmp = document.getElementById('tuijian');
    if(tmp){
      tmp.style.display = 'none';
    }

    tmp = document.getElementsByClassName('yueduad1');
    if (tmp && tmp.length > 0) { // 检查是否存在匹配的元素
      Array.from(tmp).forEach(iframe => {
        iframe.style.display = 'none';
      });
    }

    document.querySelectorAll('[title="afj"]').forEach(el => {
      el.style.display = 'none';
    });

    document.querySelectorAll('[title="bjd"]').forEach(el => {
      el.style.display = 'none';
    });

    document.querySelectorAll('[title="edc"]').forEach(el => {
      el.style.display = 'none';
    });

    document.querySelectorAll('iframe').forEach(iframe => {
      const title = iframe.title.trim();
      if (/^[A-Za-z]{3}$/.test(title)) {
        iframe.style.display = 'none';
      }
    });

    tmp = document.getElementsByClassName('bottom-ad');
    if (tmp && tmp.length > 0) { // 检查是否存在匹配的元素
      Array.from(tmp).forEach(iframe => {
        iframe.style.display = 'none';
      });
    }

    // 监听DOM变化,检测新添加的iframe
    const observer = new MutationObserver(mutations => {
      mutations.forEach(mutation => {
        mutation.addedNodes.forEach(node => {
          if (node.tagName === 'IFRAME' && /^[A-Za-z]{3}$/.test(node.title.trim())) {
            node.style.display = 'none';
            console.log("监听移除成功 title:{}", node.title)
          }
        });
      });

      let tmp2 = document.getElementsByClassName('yuedutuijian');
      if (tmp2 && tmp2.length > 0) { // 检查是否存在匹配的元素
        Array.from(tmp2).forEach(iframe => {
          iframe.style.display = 'none';
        });
      }
      
      tmp2 = document.getElementsByClassName('contentadv');
      if (tmp2 && tmp2.length > 0) { // 检查是否存在匹配的元素
        Array.from(tmp2).forEach(iframe => {
          iframe.style.display = 'none';
        });
      }

      tmp2 = document.getElementsByClassName('bg-dsp-text-center');
      if (tmp2 && tmp2.length > 0) { // 检查是否存在匹配的元素
        Array.from(tmp2).forEach(iframe => {
          iframe.style.display = 'none';
        });
      }
    });

    // 开始监听
    observer.observe(document.body, {
      childList: true,
      subtree: true
    });

})();