Skip to content

Instantly share code, notes, and snippets.

@vnegrisolo
Created September 3, 2016 14:30
Show Gist options
  • Save vnegrisolo/bbb73bab33a19e2212b8e2603d3318aa to your computer and use it in GitHub Desktop.
Save vnegrisolo/bbb73bab33a19e2212b8e2603d3318aa to your computer and use it in GitHub Desktop.
Sometimes you want to click them all. Find all elements using css selector and click them every 1 sec. I used to download all code samples from chrome extensions documentation.
var selector = 'h2 a';
var list = document.querySelectorAll(selector);
console.log('#elements to click', list.length);
list.forEach(function(el, i){
new Promise((resolve) => setTimeout(resolve, 1000*i)).then(() => {
console.log(i, el);
el.click();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment