Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

zSilver98 commented Mar 20, 2019

How to use it?

@MirMohsun

This comment has been minimized.

Copy link

MirMohsun commented Mar 20, 2019

Your code work, thank you)

@TXTFox

This comment has been minimized.

Copy link

TXTFox commented May 10, 2019

Stops working after like 25 adds.

@leogaldioli

This comment has been minimized.

Copy link

leogaldioli commented May 28, 2019

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

@mayakerem

This comment has been minimized.

Copy link

mayakerem commented Jun 1, 2019

How do we run it?

@BeatrizRSouza

This comment has been minimized.

Copy link

BeatrizRSouza commented Jun 19, 2019

Alguem sabe como executar??

@DanielBSS-dev

This comment has been minimized.

Copy link

DanielBSS-dev commented Jul 28, 2019

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

@TXTFox

This comment has been minimized.

Copy link

TXTFox commented Jul 28, 2019

@TXTFox

This comment has been minimized.

Copy link

TXTFox commented Jul 28, 2019

@DanielBSS-dev

This comment has been minimized.

Copy link

DanielBSS-dev commented Jul 29, 2019

@TXTFox

This comment has been minimized.

Copy link

TXTFox commented Jul 29, 2019

@lucaswx2

This comment has been minimized.

Copy link

lucaswx2 commented Aug 13, 2019

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);
}

}
}
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.