Created
January 25, 2025 15:06
-
-
Save trojblue/cb0b0af5a1c60a6bfe3956c445d03ac0 to your computer and use it in GitHub Desktop.
Tampermonkey script that removes scripts that block developer tools access (f12 tools)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Remove F12 Blocking | |
// @namespace http://tampermonkey.net/ | |
// @version 1.0 | |
// @description Removes scripts that block developer tools access | |
// @author YourName | |
// @match *://*/* | |
// @run-at document-start | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Override addEventListener to intercept and block debugger-blocking scripts | |
const originalAddEventListener = EventTarget.prototype.addEventListener; | |
EventTarget.prototype.addEventListener = function(type, listener, options) { | |
const modifiedListener = listener.toString(); | |
// Block common F12/dev tools detection patterns | |
const blockedPatterns = [ | |
/keydown\s*.*?(123|event\.which\s*===\s*123|event\.keyCode\s*===\s*123)/, | |
/devtoolsdetector|disable-devtool/, | |
/debugger;/ | |
]; | |
if (blockedPatterns.some(pattern => pattern.test(modifiedListener))) { | |
return; | |
} | |
originalAddEventListener.call(this, type, listener, options); | |
}; | |
// Prevent right-click disable scripts | |
['contextmenu', 'keydown'].forEach(event => { | |
document.addEventListener(event, e => e.stopImmediatePropagation(), true); | |
}); | |
// Block debugger statements from pausing execution | |
const originalDebugger = window.Debugger; | |
if (originalDebugger) { | |
window.Debugger = function() {}; | |
window.Debugger.prototype = originalDebugger.prototype; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment