Skip to content

Instantly share code, notes, and snippets.

@asifvora
Last active August 31, 2021 09:15
Show Gist options
  • Save asifvora/427eb83bafc35928acd180956359644c to your computer and use it in GitHub Desktop.
Save asifvora/427eb83bafc35928acd180956359644c to your computer and use it in GitHub Desktop.
Async/Await Essentials for Production: Loops
const timeoutPromise = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
const list = document.querySelectorAll('.L3NKy');
function clikOnLink(link){
link.click();
}
const asyncLoop = async () => {
for (let i = 0; i < list.length ; i++) {
await timeoutPromise(1000);
clikOnLink(list[i]);
}
}
asyncLoop();
@zSilver98
Copy link

How to use it?

@MirMohsun
Copy link

Your code work, thank you)

@TXTFox
Copy link

TXTFox commented May 10, 2019

Stops working after like 25 adds.

@leogaldioli
Copy link

how do I use it? I have to run on chrome evaluation?

@mayakerem
Copy link

How do we run it?

@BeatrizRSouza
Copy link

Alguem sabe como executar??

@DanielBSS-dev
Copy link

Press f12 and open console, put code there and press enter

@TXTFox
Copy link

TXTFox commented Jul 28, 2019 via email

@TXTFox
Copy link

TXTFox commented Jul 28, 2019 via email

@DanielBSS-dev
Copy link

@TXTFox
Copy link

TXTFox commented Jul 29, 2019 via email

@lucaswx2
Copy link

I've made a feel changes
`const timeoutPromise = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout));
const list = document.querySelectorAll('.L3NKy');

function clikOnLink(link){
if(link.TextContent == 'Seguir' ){
link.click();
}
}

const asyncLoop = async () => {
for (let i = 0; i < list.length ; i++) {
if(list[i].TextContent == 'Seguir' ){
clikOnLink(list[i]);
await timeoutPromise(1000);
}else{
await timeoutPromise(0);
}

}
}
`

@rahulvrema
Copy link

well this just only follow the random people but i need something else

@kanna375
Copy link

Your code work, thank you)

Bro how to use

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