Ask coding questions

← Back to all posts
bookmarklet autoclicker
CoolGuy27 (68)

does anyone know a bookmarklet autoclicker?

Comments
hotnewtop
tussiez (1675)

@tussiez
If you mean a webpage autoclicker, this is mine:
EDIT: Fixed error in code

javascript:setTimeout(function(){var n,e=prompt("Autoclick speed? Less is faster"),t=0,l=0,c=setInterval(function(){null!=n&&null!=n&&n.click()},e);document.body.addEventListener("keyup",function(e){"`"==e.key&&(null!=c?(clearInterval(c),c=void 0,alert("Stopped clicking")):c=setInterval(function(){null!=n&&null!=n&&n.click()},e))}),document.body.addEventListener("mousemove",function(e){t=e.clientX,l=e.clientY,n=document.elementFromPoint(t,l)})});```
CoolGuy27 (68)

@tussiez I don't seem to understand how to activate it, could you clarify?

tussiez (1675)

@CoolGuy27 Click on the bookmarklet.

tussiez (1675)

@CoolGuy27 Sorry, the code is bugged. In a minute or so I'll post the fixed version.

Coder100 (18819)

why not make it urself

CoolGuy27 (68)

@Coder100 i am not smart enough and trying to learn

xxpertHacker (931)

This isn't too clear, do you mean something that clicks a bookmarklet, or a bookmarklet that clicks stuff?

If you're referring to the former, that isn't possible without native code.

As for the latter, that depends on what you want to be clicked.

CoolGuy27 (68)

@xxpertHacker i am referring to the latter, and I honestly don't know what I mean myself

xxpertHacker (931)

@CoolGuy27 Well, can you give a webpage, and an example of what you want clicked? I've made plenty auto clicker scripts.

xxpertHacker (931)

@CoolGuy27 Oh, then ig all you'll need is this:

clicker: {
	"use strict";

	const { Number } = self;

	const milliseconds = Number.parseInt(
		self.prompt(
			"How many milliseconds do you want to wait before clicking again?",
			'1'
		), 10
	);

	if (false === Number.isSafeInteger(milliseconds)) {
		self.alert("Input was not an integer");

		break clicker;
	}

	// mouse coordinates
	let clientX = 0,
		clientY = 0;

	const { document } = self;

	self.setInterval(
		() => {
			// document.elementFromPoint should probably never return null, but I'm not sure
			// not all elements have #click
			document.elementFromPoint(
				clientX,
				clientY
			)?.click?.();
		},
		milliseconds
	);

	document.addEventListener(
		"mousemove",
		event => {
			({ clientX, clientY } = event);
		}, {
			passive: true
		}
	);
}

Tested it myself.

And the minified bookmarklet:

javascript:clicker:{"use strict";const{Number}=self;const milliseconds=Number.parseInt(self.prompt("How many seconds do you want to wait before clicking again?",'1'),10);if(false===Number.isSafeInteger(milliseconds)){self.alert("Input was not an integer");break clicker;}let clientX=0,clientY=0;const{document}=self;self.setInterval(()=>{document.elementFromPoint(clientX,clientY)?.click?.();},milliseconds);document.addEventListener("mousemove",event=>{({clientX,clientY}=event);},{passive:true});}
xxpertHacker (931)

@RexGREEN Didn't design it with that in mind, it never does.