Chrome如何禁用调试器关键字或禁用暂停 [英] Chrome how to disable debugger keyword or disable pause

查看:496
本文介绍了Chrome如何禁用调试器关键字或禁用暂停的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个Never pause here,但不适用于这样的代码

I know there is a Never pause here, but it's not works for code like this

setInterval(function(){
  eval('debugger;'+Math.random())
},1000)

如果找不到setInterval,则无法禁用暂停,这很烦人.

If I can't find the setInterval, I can not disable the pause, it's very annoying.

是否有任何标记或以某种方式禁用此功能?

Is there any flag or somehow to disable this ?

编辑

我发现了这个问题(DevTools:无法在测试中

I found this issues(DevTools: impossible to disable a breakpoint caused by "debugger" statement) relate to this problem, in the test code I found a flag --expose-debug-as debug, but how can I use this flag for headless,

chrome --expose-debug-as debug --headless --disable-gpu '<URL>' --repl
[0610/020053.677043:ERROR:headless_shell.cc(459)] Open multiple tabs is only supported when the remote debug port is set.

推荐答案

您真正唯一的选择是将代码注入覆盖eval的页面并将其删除.

Well the only choice you really have is to inject code into the page that overrides eval and removes it.

(function () {
  var _eval = window.eval;
  window.eval = function (str) {
    _eval(str.replace(/debugger;/,""));
  };
}());
eval("debugger;alert('a');")

这篇关于Chrome如何禁用调试器关键字或禁用暂停的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆