Created
September 3, 2016 14:30
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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