Skip to content

Instantly share code, notes, and snippets.

@anhwaivo
Last active January 14, 2026 00:47
Show Gist options
  • Select an option

  • Save anhwaivo/28980868ae03db277ab28fc23a081f81 to your computer and use it in GitHub Desktop.

Select an option

Save anhwaivo/28980868ae03db277ab28fc23a081f81 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Anti Anti-debugger
// @namespace http://tampermonkey.net/
// @version 1
// @description anti anti debug i got idea from other scripts
// @author anhwaivo
// @match *
// @include *
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
(function() {
var interval = setInterval(function() {
unsafeWindow.console.clear = () => {};
}, 0);
window.onload = function() {
clearInterval(interval);
};
var _constructor = unsafeWindow.Function.prototype.constructor;
// Hook Function.prototype.constructor
unsafeWindow.Function.prototype.constructor = function() {
var fnContent = arguments[0];
if (fnContent) {
if (fnContent.includes('debugger')) { // An anti-debugger is attempting to stop debugging
var caller = Function.prototype.constructor.caller; // Non-standard hack to get the function caller
var callerContent = caller.toString();
if (callerContent.includes(/\bdebugger\b/gi)) { // Eliminate all debugger statements from the caller, if any
callerContent = callerContent.replace(/\bdebugger\b/gi, ''); // Remove all debugger expressions
eval('caller = ' + callerContent); // Replace the function
}
return (function () {});
}
}
// Execute the normal function constructor if nothing unusual is going on
return _constructor.apply(this, arguments);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment