// ==UserScript==
// @name ProcessOn 广告屏蔽器增强版
// @namespace http://tampermonkey.net/
// @version 0.7
// @description 屏蔽 ProcessOn 网站上的广告。如果觉得好用,欢迎扫码赞赏,您的支持是我持续更新的动力!
// @author Your name
// @license MIT
// @match https://www.processon.com/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 创建样式
const style = document.createElement('style');
style.textContent = `
/* 首页顶部广告 */
div.advert,
/* 特定广告容器 */
div[style*="background-color: rgb(176, 106, 251)"],
/* 弹窗广告 */
.dialog-box[data-type="ad"],
/* 促销广告 */
a[href*="/ac/250205"],
/* 轮播广告 */
.carsouselBox,
div[class*="carsouselBox"],
div[data-v-58b88906].carsouselBox,
/* 管理弹窗广告 */
.dlg-manage,
div[class="dlg-manage"],
div[class*="dlg-manage"],
/* 年度报告广告 */
.po-report,
div[class="po-report"],
div[class*="po-report"] {
display: none !important;
opacity: 0 !important;
visibility: hidden !important;
pointer-events: none !important;
}
`;
document.head.appendChild(style);
// 定期检查并移除广告元素
function removeAds() {
// 精确的广告选择器
const adSelectors = [
'div.advert',
'div[style*="background-color: rgb(176, 106, 251)"]',
'.dialog-box[data-type="ad"]',
'a[href*="/ac/250205"]',
'.carsouselBox',
'div[data-v-58b88906].carsouselBox',
'div[class*="carsouselBox"]',
'.dlg-manage',
'div[class="dlg-manage"]',
'div[class*="dlg-manage"]',
'.po-report',
'div[class="po-report"]',
'div[class*="po-report"]'
];
// 移除匹配的广告元素
adSelectors.forEach(selector => {
try {
document.querySelectorAll(selector).forEach(element => {
if (element.classList.contains('advert') ||
element.style.backgroundColor === 'rgb(176, 106, 251)' ||
element.classList.contains('carsouselBox') ||
element.classList.contains('dlg-manage') ||
element.classList.contains('po-report') ||
(element.getAttribute('href') && element.getAttribute('href').includes('/ac/250205'))) {
element.remove();
}
});
} catch (e) {
console.log('Error removing ad:', e);
}
});
// 特别处理:移除包含特定图片的元素
document.querySelectorAll('img[src*="pocdn.processon.com/admin/file_img"], img[src*="pocdn.processon.com/admin/popup_img"], img[src*="/image/beca4be061a.png"]').forEach(img => {
const parent = img.closest('div[data-v-58b88906], div.dlg-manage, div.po-report');
if (parent) {
parent.remove();
}
});
// 移除带有特定样式的弹窗
document.querySelectorAll('div[style*="position: fixed"][style*="z-index: 11"], div.po-report').forEach(element => {
if (element.querySelector('img[src*="pocdn.processon.com/admin/popup_img"]') ||
element.querySelector('img[src*="/image/beca4be061a.png"]')) {
element.remove();
}
});
// 移除年度报告相关元素
document.querySelectorAll('.po-year-check-box, .po-report-close').forEach(element => {
const parent = element.closest('.po-report');
if (parent) {
parent.remove();
}
});
}
// 立即执行一次
removeAds();
// 页面加载完成后执行
window.addEventListener('load', removeAds);
// 创建观察器监听 DOM 变化
const observer = new MutationObserver((mutations) => {
mutations.forEach(mutation => {
if (mutation.addedNodes.length || mutation.type === 'attributes') {
removeAds();
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
attributeFilter: ['style', 'class']
});
// 每2秒检查一次广告
setInterval(removeAds, 2000);
// 重写广告关闭函数
if (typeof window.getAdvert === 'undefined') {
window.getAdvert = {};
}
window.getAdvert.hideAdvert = function() {
removeAds();
};
})();