Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
SubtleClickAll; Takes a CSS selector and executes the click method on each matching element.
javascript:function%20SubtleClickAll(SELECTOR,timeout){timeout=timeout||0;var%20node,nodes=Array.prototype.slice.call(document.querySelectorAll(SELECTOR));function%20NEXT(){node=nodes.pop();if(node)setTimeout(function(){node.click();NEXT();},timeout);};NEXT();};SubtleClickAll(prompt(%22SubtleClickAll%20(Thomas%20Aylott%20subtleGradient.com)%22,%22CSS3%20Selector%22),10);
<a href="javascript:function%20SubtleClickAll(SELECTOR,timeout){timeout=timeout||0;var%20node,nodes=Array.prototype.slice.call(document.querySelectorAll(SELECTOR));function%20NEXT(){node=nodes.pop();if(node)setTimeout(function(){node.click();NEXT();},timeout);};NEXT();};SubtleClickAll(prompt(%22SubtleClickAll%20(Thomas%20Aylott%20subtleGradient.com)%22,%22CSS3%20Selector%22),10);" title="SubtleClickAll (Thomas Aylott subtleGradient.com)">SubtleClickAll</a>
<hr />
Known to work in Safari beta 4. Has not been tested anywhere else.<br />
Could also work in IE8 or Firefox 3.1+ or Safari 3.1+
function SubtleClickAll(SELECTOR,timeout){
timeout=timeout||0;
var node,nodes=Array.prototype.slice.call(document.querySelectorAll(SELECTOR));
function NEXT(){
node=nodes.pop();
if(node)setTimeout(function(){node.click();NEXT();},timeout);
};NEXT();
};
SubtleClickAll(prompt("SubtleClickAll (Thomas Aylott subtleGradient.com)","CSS3 Selector"),10);
javascript:function%20SubtleClickAllJr(SELECTOR)%20{Array.prototype.slice.call(document.querySelectorAll(SELECTOR)).forEach(function(node)%20{node.click();});};SubtleClickAllJr(prompt(%22SubtleClickAll%20(Thomas%20Aylott%20subtleGradient.com)%22,%22CSS3%20Selector%22));
function SubtleClickAllJr(SELECTOR) {
Array.prototype.slice.call(document.querySelectorAll(SELECTOR)).forEach(function(node) {
node.click();
});
};
SubtleClickAllJr(prompt("SubtleClickAllJr (Thomas Aylott subtleGradient.com)","CSS3 Selector"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment