Greasy Fork is available in English.
IT之家 删除/去除/屏蔽目录广告去除 【QQ音乐、会员、wps、夸克、svip】等广告
// ==UserScript==
// @name IT之家 删除去除屏蔽目录广告 【会员等广告】
// @namespace http://greasyfork.icu/zh-CN/users/722555-vveishu
// @version 1.0.1
// @description IT之家 删除/去除/屏蔽目录广告去除 【QQ音乐、会员、wps、夸克、svip】等广告
// @author vveishu
// @match https://*.ithome.com/*
// @icon https://www.ithome.com/favicon.ico
// @grant 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() {
// 使用正则表达式筛选有广告文本的元素
return /^QQ ?音乐$|^大?会员$|^wps$|^夸克$|^svip$/.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);
})();