// ==UserScript==
// @name 通用Debugger拦截器
// @namespace http://tampermonkey.net/
// @version 1.0
// @description 拦截并阻止网站使用debugger进行反调试
// @author doubao
// @match *://*/*
// @grant document-start
// ==/UserScript==
(function() {
'use strict';
// Hook构造函数
Function.prototype._constructor = Function.prototype.constructor;
Function.prototype.constructor = function() {
if (arguments.toString().includes("debugger")) {
return null;
}
return Function.prototype._constructor.apply(this, arguments);
};
// Hook Function
const F_ = Function;
Function = function(s) {
if (s === 'debugger') {
return () => {};
}
return F_.apply(this, arguments);
};
Function.prototype = F_.prototype;
// Hook eval
const eval_ = eval;
eval = function(a) {
if (a && a.toString().includes("debugger")) {
return "";
}
return eval_.call(window, a);
};
// Hook setInterval
const setInterval_back = setInterval;
setInterval = function(a, b) {
if (a.toString().includes('debugger')) {
return null;
}
return setInterval_back.apply(this, arguments);
};
// Hook setTimeout
const setTimeout_back = setTimeout;
setTimeout = function(a, b) {
if (a.toString().includes('debugger')) {
return null;
}
return setTimeout_back.apply(this, arguments);
};
// Hook HTML插入
const oldAppendChild = Node.prototype.appendChild;
Node.prototype.appendChild = function() {
if (arguments[0] && arguments[0].innerHTML && arguments[0].innerHTML.indexOf('debugger') !== -1) {
arguments[0].innerHTML = arguments[0].innerHTML.replace(/debugger/g, '');
}
return oldAppendChild.apply(this, arguments);
};
// Hook属性设置
const oldSetAttribute = Element.prototype.setAttribute;
Element.prototype.setAttribute = function(name, value) {
if (name === 'onload' && value.includes('debugger')) {
value = value.replace(/debugger/g, '');
}
return oldSetAttribute.apply(this, arguments);
};
console.log('[Debugger拦截器] 已启动,正在保护您的浏览器环境');
})();
通用Debugger拦截器
于 2025-06-20 13:20:43 首次发布