Skip to content

Instantly share code, notes, and snippets.

@asifvora
Last active August 31, 2021 09:15
Show Gist options
  • Select an option

  • Save asifvora/427eb83bafc35928acd180956359644c to your computer and use it in GitHub Desktop.

Select an option

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();
@TXTFox

TXTFox commented Jul 29, 2019 via email

Copy link
Copy Markdown

@lucaswx2

Copy link
Copy Markdown

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
Copy Markdown

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

@kanna375

Copy link
Copy Markdown

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