Search code examples
javascriptclickbookmarklettumblr

Bookmarklet: Click All Like Buttons On Tumblr


Similar to this Follow all users on a twitter page, I am trying to change this to click all the "like" hearts on a Tumblr page instead of the follow button:

javascript:$('.button.follow-button').click()

Thanks


Solution

  • javascript:var a = document.getElementsByTagName('a'); var b = []; for(var i=0, len = a.length; i < len; i++){ if(a[i].id.indexOf('like_button') !== -1){b.push(a[i]) } }; for(var i=0, len = b.length; i < len; i++){ b[i].onclick() };
    

    There. What it does is gets all the a tags on the page. Then filters them and finds all the like buttons. Then it just clicks on them.

    Note that this solution is pretty inefficient and you should probably be using document.getElementsByClassName as Samuel did, but that may not be supported in all browsers (I'm looking at you, IE 8).