Skip to content

JavaScript – Click all buttons with Class Name after 5 seconds (Twitter)

I’ve been trying to get my script to work for ages now, and it just won’t have it! I’m trying to click all the ‘unfollow button’s on my Twitter/Following page after 5 seconds. Here’s my code without the setInterval function:

var buttonArray = document.getElementsByClassName('w-button-common w-button-unfollow'); for(var a=0;a<buttonArray.length;a++){ buttonArray[0].click(); } 

Here’s Twitters HTML DOM code for the unfollow buttons:

    <span class="w-button-common w-button-unfollow"><input alt="Follow" src="" type="image"></span>
  <input type="hidden" name="scribe_item" value="description=list&amp;id=1875185790&amp;item_type=3">

I’d be so appreciated if someone could amend my code! Thank you so much in advance!


Change buttonArray[0].click() to buttonArray[a].click().