3 ms·
If you're already using setTimeout, why not just use it directly? function clickLoop() { document.querySelector('.main-btn').click(); setT
by hombre_fatal 2y ago
If you're already using setTimeout, why not just use it directly?
function clickLoop() {
document.querySelector('.main-btn').click();
setTimeout(clickLoop, 50)
}
- jampekka 2y agoThat's an infinite loop.
- deleted 2y ago[deleted]
- akx 2y agoBreakable by `clickLoop = null`.
- eterm 2y agoWhat's all this overengineering and waste creating timeouts? Why not just use setInterval? let interval = setInterval(() => document.querySelector('.main-btn').click(), 50) Then clearInterval(interval) to stop
- hombre_fatal 2y agoHow could you be so wasteful traversing the DOM tree every time to find .main-btn? Shame on you.