Click all elements matching a CSS selector via Chrome DevTools console

Published by Søren Houen on

Clicking all trash buttons on a page of GitHub stale branches Clicking all trash buttons on a page of GitHub stale branches

Click all CSS-selected elements without jQuery

I sometimes need to click all elements on a webpage, for instance to:

I struggled to do this without using jQuery, but now found a way, using chrome’s built-in $$ operator:

Here the CSS selector is button[aria-label=\"Delete branch\"], but it can of course be whatever you need:

$$("button[aria-label=\"Delete branch\"]").map(e => e.click())

What can you use this for?

Quickly clean up stale branches on Github

Best, Søren

· chrome, devtools, console, quick tips