Cole's Notes

A Simple Blog Powered by Go

Just a Cutesy Browser Clicker

Posted by cole on May 8, 2025 00:27

Have you ever needed to click a button, but felt the burn of carpal tunnel destroying your wrists, and therefore your livelihood? (Definitely a legitimate concern, this is absolutely an accessibility tool and not explicitly against terms of services)

Here's a quick little JavaScript snippet you can paste in your terminal, customize, and let rip to save you those precious keystrokes.

(function pressLTimes(times, minDelay, maxDelay) {
    function pressKey() {
        // keydown event
        let downEvent = new KeyboardEvent('keydown', {key: 'l', code: 'KeyL', keyCode: 76, which: 76, bubbles: true});
        document.dispatchEvent(downEvent);

        // keyup event (optional, but many sites expect both)
        let upEvent = new KeyboardEvent('keyup', {key: 'l', code: 'KeyL', keyCode: 76, which: 76, bubbles: true});
        document.dispatchEvent(upEvent);
    }

    let i = 0;

    function loop() {
        if (i++ >= times) return;
        pressKey();
        let nextDelay = Math.floor(Math.random() * (maxDelay - minDelay + 1)) + minDelay;
        setTimeout(loop, nextDelay);
    }

    loop();
})(100, 75, 150); 

How to:

  • Open your browser console (F12, Ctrl+Shift+I, or Right Click > Inspect).
  • Paste the code.
  • You can modify the 100, 75, and 150 at the bottom to adjust number of presses, minimum delay, and maximum delay in milliseconds.
    • I found these values to be reasonable on most sites.

Notes:

  • Some advanced websites may monitor actual hardware events and this may not always work, but on most websites it will.
  • You can change the 'l', 'KeyL', and 76 to simulate a different key if needed. For example, 'a', 'KeyA', and 65 for the "a" key.

Let me know if you run into any issues! You know how to reach me. πŸ˜Άβ€πŸŒ«οΈ

← Back to posts