Help with clicking "Delete all spam messages now" in Gmail

Hello all,

I am trying to automate clicking "Delete all spam messages now" link in Gmail in Safari.

What would be the best way to do this? JavaScript for automation?

Thanks,

Jim

Ok. I think I figured this out (but any corrections or suggestions are welcome:

Execute JavaScript in Safari:

document.getElementsByClassName('x2').click();

I don't think that will work since .getElementsByClassName() function will return a collection of elements. You will need to specifiy which element to click, maybe something like this if you want the first element:

document.getElementsByClassName('x2')[0].click();

but I can't be for sure without having the actual HTML of the page.

1 Like

It was working sporadically. But with your addition, it is working great now. My guess is that it is indeed the first element.

Thanks @JMichaelTX!