Black-boxing script option in Chrome Developer tool
Asked Answered
S

5

13

I have an issue with the Chrome developer tool.
My version is Version 46.0.2490.71 (64-bit)
According to online tutorials, I can go to Sources tab, right-click a script file and there will be Blackbox Script option to choose. enter image description here
However, I see no option in my chrome. How do I enable that option since I have no knowledge about regex?

noBlackBoxoption



Another problem: The scripts still got debugged even though I added them to blackbox list. Weird!!



VMFile One more thing i want to ask is how I blackbox an "unlimited" amount of VM files?

Stavropol answered 20/10, 2015 at 11:46 Comment(1)
Sounds stupid, but I just figured out a way to kip those VM files. I just need to have multiple breakpoints in the source file that I want to debug.Stavropol
S
8
  1. Open devtools settings (press F1 once in devtools or open from the menu)
  2. Go to blackboxing (see image below) enter image description here

  3. Add a pattern, for example:

    • node_modules
    • angular
    • rxjs

It uses regex syntax in case you need something more specific.

The nice part about blackboxing library/framework scripts is that it makes it easier to see in stacktraces from where the error was triggered in your own sources.

EDIT

As other pointed out, since this answer was posted you can directly blackbox a script with a right click on the source file in devtools. However head off to the blackboxing settings UI for more control.

enter image description here

Shorten answered 20/10, 2015 at 13:35 Comment(6)
I don't know Regex, so I cannot manually input the file name there.Stavropol
If you want to blackbox angular scripts as the one on your screenshot, then angular.*\.js should suffice. In case you need more than that, there are a lot of questions about regex on SO, or you can open a new one if you don't find the answer. Consider closing this one as it is about blackboxing a script in Chrome and not about regex.Shorten
This option is missing in my Chrome 54Patagonia
This no longer seems to existGrimbal
The user interface changed, I updated the answer. Thanks for noticing.Shorten
just click the mouse right button anywhere within the opened script file in the source tab and select "blackbox script"Anodic
R
7

There's an easier way in Chrome 60 (and possibly older):

  • Open the source file in Chrome dev tools (in the source tab)
  • Right Click the column that displays the line numbers
  • Select "Blackbox Script"

Looks like this

EDIT: As svict4 pointed out, in Chrome 64, you can also right click anywhere on the script

Refer answered 29/8, 2017 at 17:25 Comment(3)
On Version 64.0, Right clicking the line numbers did not bring up "Blackbox Script", but right clicking anywhere on the code itself presented that option.Whitsun
@Whitsun Thanks, looks like you're right about clicking anywhere. For me (on Mac), the sidebar still works as well.Refer
As of Chrome 102 (2022), seems to be back in the line-number column, and is now called "Add script to ignore list." (Seems like, from this post, it moves around a lot...)Veto
B
2
  • It seems they changed from blackbox to Ignore List.

enter image description here

  • Also press f1 in devTools and find Ignore List

enter image description here

Braeunig answered 22/4, 2021 at 14:6 Comment(0)
K
0

Not sure if Chrome has changed too, but on Chromium Edge, the option is named "Mark as Library Code" and "Mark as my Code" to disable it. You have to right click on the code and not on the file/tab. Right clicking on Line numbers works too.

enter image description here

Kaolin answered 15/7, 2020 at 22:57 Comment(0)
I
0
  1. Open DevTools,
  2. Find the VM##### file stopping the execution,
  3. Add a breakpoint to the debugger; statement,
  4. Edit the breakpoint and simply add false to the condition

enter image description here

Should work in any version of any chromium based browser.

Insuppressible answered 2/4 at 15:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.