Global Anti-Debugger

Removes and neutralizes any `debugger;` commands before the site runs them

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

Advertisement:

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

Advertisement:

// ==UserScript==
// @name         Global Anti-Debugger
// @namespace    https://github.com/FabioSmuu
// @version      1.0
// @description  Removes and neutralizes any `debugger;` commands before the site runs them
// @author       Fabio Smuu
// @match        *://*/*
// @run-at       document-start
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
  'use strict'

  const originalConstructor = Function.prototype.constructor
  Function.prototype.constructor = function(...args) {
    const code = args.join('')
    const sanitized = code.replace(/\bdebugger\s*;?/gi, '')
    return originalConstructor.call(this, sanitized)
  }

  const originalEval = window.eval
  window.eval = function(code) {
    if (typeof code === 'string') code = code.replace(/\bdebugger\s*;?/gi, '')
    return originalEval(code)
  }

  const observer = new MutationObserver(mutations => {
    mutations.forEach(mutation => {
      mutation.addedNodes.forEach(node => {
        if (node.tagName === 'SCRIPT' && node.textContent.includes('debugger')) {
          node.textContent = node.textContent.replace(/\bdebugger\s*;?/gi, '')
        }
      })
    })
  })

  observer.observe(document.documentElement, { childList: true, subtree: true })
})()