1

I hate having to repeatedly press "step forward" in Chrome's Javascript debugger. I've had skip forward at least 100 times on this one script I am working on. How can I make it step forward any number of times I want it to before it pauses execution once more?

Melab
  • 2,594
  • 7
  • 30
  • 51

2 Answers2

2

Have you tried setting a breakpoint?

https://developers.google.com/web/tools/chrome-devtools/debug/breakpoints/add-breakpoints?hl=en

Dror
  • 7,255
  • 3
  • 38
  • 44
  • 1
    No, because I need to find the correct place first, which is why I need to step forward N times. – Melab Jun 29 '16 at 00:54
  • Not sure what the scenario you are trying to debug but conditional breakpoint should allow you to set it to the point you want to stop. – Dror Jun 29 '16 at 01:56
0

As Dror mentioned, there are probably better ways to go about this.

However, if you really need the step forward functionality...

DevTools is a web app that you can inspect like any other page. Open the inspector and then paste this code in the console:

var times = 4;
step()
function step(){
   var btn = document.querySelector(".scripts-debug-toolbar").shadowRoot.querySelector(".step-over-toolbar-item");
    var enabled = !btn.parentNode.disabled
   if (enabled ){
     btn.dispatchEvent(new MouseEvent("click", {bubbles: true}));
     times--;
     if (times === 0){return}
     setTimeout(step, 1)
   } else {console.log("disabled");  setTimeout(step, 1) }
}

This will click on the "step over" button as many times as defined in the times varible.

Community
  • 1
  • 1
Matt Zeunert
  • 16,075
  • 6
  • 52
  • 78