Function.prototype.temp_constructor= Function.prototype.constructor; Function.prototype.constructor=function(){ if (arguments && typeof arguments[0]==="string"){ if (arguments[0]==="debugger") return "" } return Function.prototype.temp_constructor.apply(this, arguments); }; //The hook timer function replaces the debugger _setInterval = setInterval setInterval = function setInterval(code, time){ console.log(code, time) code = code.toString().replace(/debugger/, "").replace(/function ()/, "function xxx") return _setInterval(new Function(code) , time) } _setTimeout = setTimeout setTimeout = function setTimeout(code, time){ console.log(code, time) code = code.toString().replace(/debugger/, "").replace(/function ()/, "function xxx") return _setTimeout(new Function(code), time) }