强制拦截manwa广告检测
// ==UserScript==
// @name 去manwa检测广告弹窗-强制方法
// @namespace pipi
// @version 0.8
// @description 强制拦截manwa广告检测
// @run-at document-start
// @match https://manwa.me/chapter/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// 拦截可能创建弹窗的脚本
const originalCreateElement = document.createElement;
document.createElement = function(tagName) {
const element = originalCreateElement.call(this, tagName);
if (tagName.toLowerCase() === 'div') {
const originalSetAttribute = element.setAttribute;
element.setAttribute = function(name, value) {
originalSetAttribute.call(this, name, value);
// 检查是否是弹窗相关属性
if ((name === 'class' && value.includes('modal')) ||
(name === 'style' && value.includes('fixed'))) {
console.log('拦截潜在弹窗元素创建');
}
};
}
return element;
};
// 覆盖alert显示方法(针对自定义alert)
window.alert = function() {
const message = arguments[0] || '';
if (message.includes('请关闭阻挡广告插件') || message.includes('manwa.me')) {
console.log('拦截广告检测alert:', message);
return;
}
// 其他正常alert允许通过
return Function.prototype;
};
// 定期清理弹窗
setInterval(() => {
const modals = document.querySelectorAll('div[style*="fixed"], div[style*="absolute"]');
modals.forEach(modal => {
if (modal.textContent.includes('请关闭阻挡广告插件') ||
modal.textContent.includes('manwa.me 显示')) {
modal.remove();
console.log('已移除广告弹窗');
}
});
}, 1000);
})();