// ==UserScript== // @name IT之家 删除去除屏蔽目录广告 【会员等广告】 // @namespace https://greasyfork.org/zh-CN/users/722555-vveishu // @version 1.0 // @description IT之家 删除/去除/屏蔽目录广告去除 【QQ音乐、会员、wps、夸克】等广告 // @author vveishu // @match https://*.ithome.com/* // @icon https:/www.ithome.com/favicon.ico // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... function displaynone(){ // 选择所有li元素 $('li').each(function() { // 查找当前li元素下的class为tags的后代元素中的a子元素 var matchingAs = $(this).find('.tags a').filter(function() { // 使用正则表达式筛选文本为“音乐”或“会员”的a元素 return /^QQ ?音乐$|^大?会员$|^wps$|^夸克$/.test($(this).text()); }); // 如果找到匹配的a元素,则隐藏该li元素 if (matchingAs.length > 0) { $(this).css('display', 'none'); } }); } //确保 DOM 完全加载后再执行代码 $(document).ready(displaynone()); // 目标元素 const targetElement = document.querySelector('#list .bl'); const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.type === 'childList') { console.log('子元素发生变化'); // 执行相应的处理逻辑 displaynone(); } }); }); // 配置子元素观察器 const config = { childList: true, }; observer.observe(targetElement, config); })();