Instantly share code, notes, and snippets.

Embed
What would you like to do?
find a bunch of stuff on the page and click on them
var divs = document.querySelectorAll('.button'); [].forEach.call(divs, function(div) { div.click();});
@eviltester

This comment has been minimized.

Show comment
Hide comment
@eviltester

eviltester Aug 16, 2018

  1. Use the dev tools to view the dom
  2. Use 'find' to create a css selector that matches all the things you want to click on
  3. Change the '.button' in the gist to the css selector you created
  4. Enter the Javascript into the console
  5. Hopefully everything you wanted clicked, is now clicked

Iteration pattern from:

https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

MDN Click

https://developer.mozilla.org/en-US/docs/Web/Events/click

Alternative click approaches:

https://stackoverflow.com/questions/2381572/how-can-i-trigger-a-javascript-event-click

Owner

eviltester commented Aug 16, 2018

  1. Use the dev tools to view the dom
  2. Use 'find' to create a css selector that matches all the things you want to click on
  3. Change the '.button' in the gist to the css selector you created
  4. Enter the Javascript into the console
  5. Hopefully everything you wanted clicked, is now clicked

Iteration pattern from:

https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

MDN Click

https://developer.mozilla.org/en-US/docs/Web/Events/click

Alternative click approaches:

https://stackoverflow.com/questions/2381572/how-can-i-trigger-a-javascript-event-click

@eviltester

This comment has been minimized.

Show comment
Hide comment
@eviltester

eviltester Aug 16, 2018

I've also used the same approach in an interval to banish adverts that are on the page and continue to appear in 'infinite scroll pages'

e.g.

setInterval(function(){
var advert = document.querySelector(".dismiss-advert");
if(advert){advert.click();}
},200);
Owner

eviltester commented Aug 16, 2018

I've also used the same approach in an interval to banish adverts that are on the page and continue to appear in 'infinite scroll pages'

e.g.

setInterval(function(){
var advert = document.querySelector(".dismiss-advert");
if(advert){advert.click();}
},200);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment