Reputation: 2822
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?
Upvotes: 1
Views: 416
Reputation: 16561
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.
Upvotes: 0
Reputation: 7303
Have you tried setting a breakpoint?
https://developers.google.com/web/tools/chrome-devtools/debug/breakpoints/add-breakpoints?hl=en
Upvotes: 2