Frontend Development

JavaScript Auto-Clicker(s)

Submitted by Yondu, , Thread ID: 197769

Thread Closed
12-02-2021, 10:25 PM
#1
There's 2 different scripts I have, you may choose whichever one you would like to use. Both scripts achieve the same goal. Tongue


Code:
id = "clicker"
var button = document.getElementById("clicker");

setInterval(function()
{
    button.click()
}, 0)

Code:
var button = document.getElementsByClassName("btn btn-default")[0];

setInterval(function()
{
    button.click()
}, 0)
[Image: wsUuw16j6oyxLLRnnK.gif]

RE: JavaScript Auto-Clicker(s)

#2
Well the same goal is good, but can you tell whic one is fastest and makes low processing time to compile?

RE: JavaScript Auto-Clicker(s)

OP
#3
19-02-2021, 12:02 AM
NCRRancho Wrote:
Well the same goal is good, but can you tell whic one is fastest and makes low processing time to compile?

I haven't tested this in a while. But I think they both just are more likely doing the same thing.

There isn't a specific faster and slower one.
[Image: wsUuw16j6oyxLLRnnK.gif]

RE: JavaScript Auto-Clicker(s)

#4
19-02-2021, 12:04 AM
Yondu Wrote:
I haven't tested this in a while. But I think they both just are more likely doing the same thing.

There isn't a specific faster and slower one.
Well yeah, but when you get about 10k+ rows in code, it feels different

RE: JavaScript Auto-Clicker(s)

OP
#5
19-02-2021, 12:09 AM
NCRRancho Wrote:
Well yeah, but when you get about 10k+ rows in code, it feels different

To be honest I haven't really tested it out with 10k+ rows in code whoops.

This makes more sense.
[Image: wsUuw16j6oyxLLRnnK.gif]

RE: JavaScript Auto-Clicker(s)

#6
I prefer the first one code.

RE: JavaScript Auto-Clicker(s)

#7
prefer get element by id, because is more faster than search by className (because using id you will return the first element with id, when code return the element, break the search; And searching by className you will return more than one element, that's very slow)

i prefer that

```js
const elementId = "clicker";
const button = document.getElementById(elementId);

const taskId = setInterval(() => button.click(), 0);

const cancelAutoClick = () => clearInterval(taskId);
```

Users browsing this thread: 4 Guest(s)