News for hackers. Stuff that matters.
Re:Stimulation Clicker by ipsum2 on Monday January 06, 2025 @01:47PM (#42613824)
Running it async will prevent the main screen from lagging:

  (async () => {
    const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
    for (let i = 0; i < 10000; i++) {
        document.getElementsByClassName('main-btn')[0].click();
        await delay(5); // 5 ms sleep
    }
  })();
Re:Stimulation Clicker by hombre_fatal on Monday January 06, 2025 @01:54PM (#42613942)
If you're already using setTimeout, why not just use it directly?

    function clickLoop() {
        document.querySelector('.main-btn').click(); 
        setTimeout(clickLoop, 50) 
    }
Re:Stimulation Clicker by eterm on Monday January 06, 2025 @03:04PM (#42614995)
What'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
Re:Stimulation Clicker by hombre_fatal on Monday January 06, 2025 @06:13PM (#42617198)
How could you be so wasteful traversing the DOM tree every time to find .main-btn? Shame on you.
Re:Stimulation Clicker by jampekka on Monday January 06, 2025 @02:19PM (#42614329)
That's an infinite loop.
Re:Stimulation Clicker by akx on Monday January 06, 2025 @02:45PM (#42614729)
Breakable by `clickLoop = null`.
Re:Stimulation Clicker by phelipetls on Monday January 06, 2025 @05:15PM (#42616607)
Or use requestAnimationFrame to run infinitely at ~60fps

    window.requestAnimationFrame(function clickButton() {
        document.querySelector(".main-btn").click()
        window.requestAnimationFrame(clickButton)
    })
Re:Stimulation Clicker by 65 on Monday January 06, 2025 @07:09PM (#42617662)
This doesn't seem to logarithmically scale when you get the click percent increase upgrade, while the other code does.
Re:Stimulation Clicker by i8i76876 on Thursday January 09, 2025 @08:29AM (#42645202)
7i67i76i76i76i798778kiki87778uuuuuuuujjjjjjjkkkkkkkk