Skip to content

Instantly share code, notes, and snippets.

@asteriskman7
Created September 24, 2020 18:32
Show Gist options
  • Save asteriskman7/3e4114a8ff22f1eeee3a12a7d9f36b8b to your computer and use it in GitHub Desktop.
Save asteriskman7/3e4114a8ff22f1eeee3a12a7d9f36b8b to your computer and use it in GitHub Desktop.
simple javascript autoclicker
let _button=4;
let _ID;
document.body.addEventListener('mousedown', (e)=>{if(e.button===_button){_ID=_ID||setInterval(()=>e.target.click(),1)}});
document.body.addEventListener('mouseup', (e)=>{if(e.button===_button){clearInterval(_ID);_ID=0}});
@BANANALEADER
Copy link

what

@BANANALEADER
Copy link

how do you use it

@asteriskman7
Copy link
Author

asteriskman7 commented Mar 6, 2022

@BANANALEADER
Select the mouse button you want to use for autoclicking.
Modify line 1 if the button you want to use for autoclicking isn't button 4.
Paste the code into the console of the web page.
Hold down the button you've selected and it will be clicked rapidly as long as the button continues to be held on the page.

@Xxgamersirrico
Copy link

how do we type fast

@asteriskman7
Copy link
Author

This code doesn't let you type fast. It simulates mouse clicks.

@TheNeighboor
Copy link

This is really cool, thanks for making it.

@asteriskman7
Copy link
Author

@TheNeighboor You're welcome. Glad you're finding it useful.

@gottem87
Copy link

for let _button=4;
what number would i use for right click?
Left click?

@asteriskman7
Copy link
Author

asteriskman7 commented Oct 18, 2022 via email

@gottem87
Copy link

Pretty sure that left is 1 and right is 3. You can try a few values if your initial guess doesn't work as intended.

On Mon, Oct 17, 2022, 9:20 PM gottem87 @.> wrote: @.* commented on this gist. ------------------------------ for let _button=4; what number would i use for right click? Left click? — Reply to this email directly, view it on GitHub https://gist.github.com/3e4114a8ff22f1eeee3a12a7d9f36b8b#gistcomment-4339183, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACT57EPZXZXHAWL4DD6AE2DWDX3PPANCNFSM5P63WZCA . You are receiving this because you authored the thread.Message ID: @.***>

What about spacebar?

@asteriskman7
Copy link
Author

This code does not support using the keyboard to enable auto clicking.

@gottem87
Copy link

It did not seem to work.
let _button=[3 and 1];
let _ID;
document.body.addEventListener('mousedown', (e)=>{if(e.button===_button){_ID=_ID||setInterval(()=>e.target.click(),1)}});
document.body.addEventListener('mouseup', (e)=>{if(e.button===_button){clearInterval(_ID);_ID=0}});

@asteriskman7
Copy link
Author

I was wrong about the button number mapping. The mapping is like this:
0 = left
1 = middle
2 = right

@simoncat01
Copy link

so full code is what

@asteriskman7
Copy link
Author

The full code is what is in the gist at the top. My mouse has more than 3 buttons so I used button 4. If you want to use another button, like the middle mouse button, you would replace the 4 on the first line with a 1.

@Pokeknight2610
Copy link

any way to do on replit
so I don't have to do inspect
help
please
I'm on managed cb

@asteriskman7
Copy link
Author

I can't say specifically for replit. I've never used it. But, if you put everything into one line and prefix it with "javascript:" and paste it into the browser's address bar and hit enter it should work just as good as putting it in the browser console:
javascript:let _button=4;let _ID;document.body.addEventListener('mousedown', (e)=>{if(e.button===_button){_ID=_ID||setInterval(()=>e.target.click(),1)}});document.body.addEventListener('mouseup', (e)=>{if(e.button===_button){clearInterval(_ID);_ID=0}});

@funydoge
Copy link

funydoge commented May 3, 2024

it works LOLLLL. I used it on a cps test page and got a max of 175 and an average of 50

@asteriskman7
Copy link
Author

🎉

@dontrizz
Copy link

@BANANALEADER Select the mouse button you want to use for autoclicking. Modify line 1 if the button you want to use for autoclicking isn't button 4. Paste the code into the console of the web page. Hold down the button you've selected and it will be clicked rapidly as long as the button continues to be held on the page.

how do you get to that

@asteriskman7
Copy link
Author

Get to what? The console? On chrome desktop you can press F12 and select the "Console" tab. On other desktop browsers it's probably similar but you can google "How to open console for browser". On mobile browsers you probably can't and you probably aren't using a mouse on your mobile device so it doesn't matter anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment