remove-debugger

移除 eval 和 Function 中的 debugger 语句

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name            remove-debugger
// @namespace       https://github.com/pansong291/
// @version         0.0.2
// @description     移除 eval 和 Function 中的 debugger 语句
// @author          paso
// @license         Apache-2.0
// @match           *://*/*
// @icon
// @grant           none
// @run-at          document-start
// ==/UserScript==

;(function () {
  'use strict'
  const oEval = window.eval
  const oFunction = window.Function
  const handleArgs = (args, last) => {
    if (!args?.length) return
    const ind = last ? args.length - 1 : 0
    if (!args[ind]?.replaceAll) return
    args[ind] = args[ind].replaceAll(/\bdebugger\b/g, ';/*debugger*/;')
  }
  window._original_eval = oEval
  window._original_Function = oFunction
  window.eval = new Proxy(oEval, {
    apply(target, thisArg, argArray) {
      handleArgs(argArray, false)
      return target.apply(thisArg, argArray)
    }
  })
  window.Function = new Proxy(oFunction, {
    apply(target, thisArg, argArray) {
      handleArgs(argArray, true)
      return target.apply(thisArg, argArray)
    },
    construct(target, argArray, newTarget) {
      handleArgs(argArray, true)
      return new target(...argArray)
    }
  })
  oFunction.prototype.constructor = window.Function
}())