Essay - Published: 2024.11.08 | create | javascript | tech |
DISCLOSURE: If you buy through affiliate links, I may earn a small commission. (disclosures)
I recently stumbled upon Neal.fun's Sun vs Moon clicker. I noticed that sun was losing to moon by a large margin which is a travesty as we all need the sun to survive. So I decided to do smth about it.
Here we build an auto-clicker bot that runs directly in our browser so we can automate clicks (and points!) for the team of our choice - here sun.
The clicker game itself is pretty simple:
Thus to increase points for our team we just need to automate button clicks.
Most browsers allow you to run arbitrary javascript in them which is great for customizability. We'll leverage that to build ourselves a little autoclicker.
First we need to be able to find the button we need to click. By inspecting the HTML we can see that the sun button has an id - sun-btn. We'll use that to find it on the page.
Then we build a little script we can paste into the browser's console which will tell the browswer to click the button on an interval:
sun-btnCode:
const clickInterval = setInterval(() => {
const button = document.getElementById('sun-btn');
if (button) {
button.click();
if(Math.random() <= 0.01) {
console.log('Button clicked ~100 times');
}
} else {
console.log('Button not found');
clearInterval(clickInterval); // Stop if button disappears
}
}, 200);
I tried increasing the click rate to 10 / second but quickly ran into rate limits so I think 5 / second is around the most we can do for a long time.
If you liked this post you might also like:
The best way to support my work is to like / comment / share for the algorithm and subscribe for future updates.