Like Everything on Facebook with this JavaScript Bookmarklet

March 15th, 2011 | 12,256 views | 44 Comments » |

Do you want to like every post and comment that you see on Facebook all at once? Well, it’s your lucky day.

Drag the link below to your Bookmarks Bar and click it to automatically like all the posts and comments on the page you’re on.

I Like Everything

(drag me to your bookmarks bar, go to Facebook, then click me!)

Why’d I do this? Some friends and I were playing around with Facebook’s new comment-on-enter feature and we got a large 70+ comment thread going, then people began to like every comment in the thread, so the idea for this JavaScript bookmarklet was born. I whipped it up in 15 minutes.

Facebook Like Bomb - Tons of notifications.

Source Code:

If you are curious how this works, here is theĀ abbreviatedĀ source code:

var sad = document.getElementsByTagName('button');
var happy = [];

// Select only the Like buttons.
// Convert the sad NodeList to a happy Array.
for (var i = 0; i < sad.length; i++) {
    if (sad[i] && (sad[i].title == 'Like this comment' || sad[i].title == 'Like this item')) {
        happy.push(sad[i]);
    }
}

function happyFn(happy) {
    if (happy.length <= 0) {
        return;
    }
    happy[0].click();

    // Wait for each Like to be processed before trying the next.
    // Facebook enforces this requirement.
    window.setTimeout(function() {
        happyFn(happy.splice(1));
    }, 800);
}
happyFn(happy);

Get the full source code on GitHub.

Bookmarklet Source:

And here is the source of the bookmarklet, perfect for copy-pasting into a convenient bookmark. Or just, drag this link to your bookmarks bar.

javascript:var s = document.getElementById('happyScript');
if (s) {
    s.parentNode.removeChild(s);
}
s = document.createElement('script');
s.setAttribute('src', 'http://www.feross.org/hacks/like_everything/like_everything.js');
s.setAttribute('type', 'text/javascript');
s.setAttribute('id', 'happyScript');
document.body.appendChild(s);
void(0); // don't redirect

Update:

I just updated the bookmarklet to show some UI about the progress of your “like bomb”, as well as a button to stop the liking if you suddenly have a change of heart. Everyone’s bookmarklets should be updated automatically. Go here if you want the updated source code.

Update 2:

I just fixed a bug in Firefox where clicking the bookmarklet causes the browser to redirect to a page with the message [object HTMLScriptElement] shown. You should update your bookmarklet. It turns out that you need to end all JavaScript code within links and bookmarklets with void(0); or else the browser will try to follow the link.

You should share this with your friends:

44 Comments | Leave a comment » More posts about: Hacks

44 Comments on “Like Everything on Facebook with this JavaScript Bookmarklet”

  1. 1 David said at 11:24 pm on March 15th, 2011:

    Is the 1.5s timeout necessary? It takes a long time to like all those comments :P

  2. 2 Feross Aboukhadijeh said at 11:30 pm on March 15th, 2011:

    David, the delay is necessary since Facebook only allows one Like button to be clicked on at a time. While one Like is being processed all the other Like buttons are disabled.

    I changed the delay to 1000ms and it feels much better.

  3. 3 Matt Bush said at 11:46 pm on March 15th, 2011:

    Added a line to make it flash red when clicked as well. Watch it cascade down the screen!

    javascript:var%20sad=document.getElementsByTagName(‘button’);var%20happy=[];for(var%20i=0;i<sad.length;i++){if(sad[i]&&sad[i].title=='Like%20this%20comment'||sad[i].title=='Like%20this%20item'){happy.push(sad[i]);}}%20function%20happyFn(happy){if(happy.length<=0){return;}%20happy[0].click();happy[0].style.color='#FF0000';window.setTimeout(function(){happyFn(happy.splice(1));},1000);}%20happyFn(happy);

  4. 4 Feross Aboukhadijeh said at 12:44 am on March 16th, 2011:

    Thanks Matt! I used your red style idea in the updated version of the script I just posted.

  5. 5 Andrew said at 1:29 am on March 16th, 2011:

    When I’m using the bottom bookmarklet, it only likes one post, starting with the top, instead of liking multiple posts on a page.

  6. 6 @Iconic88 said at 1:52 am on March 16th, 2011:

    You’re a legend Feross ;)

    Thanks!

  7. 7 Feross Aboukhadijeh said at 2:11 am on March 16th, 2011:

    I recently changed the bookmarklet, Andrew. Delete your old one and try it again.

  8. 8 Feross Aboukhadijeh said at 2:11 am on March 16th, 2011:

    Iconic88, thanks! Glad you like it!

  9. 9 smackwho said at 3:32 am on March 16th, 2011:

    Very smooth js. Not sure I would ever use it though because I rarely like everything that everyone has to say and would want to give some goober the wrong idea. :) You do rock!

  10. 10 Ron said at 5:08 pm on March 17th, 2011:

    I love your previous work. Can’t seem to get this to work for me. It redirects to a javascript URL with ‘[object HTMLScriptElement]‘ shown. I may have done something on my end as I know nothing of javascript.

  11. 11 aletss said at 5:19 pm on March 17th, 2011:

    how do you do this?

  12. 12 Giuseppe said at 4:14 am on March 19th, 2011:

    Hey Feross that’s nice…
    here my improvement:

    http://giuseppegurgone.com/like_everything.js

    that version should work with any languages :)

  13. 13 Dan Ross said at 4:43 am on March 19th, 2011:

    Does this like the ads as well?

  14. 14 Rajesh said at 6:43 am on March 23rd, 2011:

    Good tips!

  15. 15 alan said at 8:35 pm on March 24th, 2011:

    hey man facebook is cracking down on liking too fast. is there one that is time delayed?

  16. 16 Feross Aboukhadijeh said at 4:17 pm on March 28th, 2011:

    @Alan – What do you mean Facebook is cracking down? What behavior are you seeing?

  17. 17 Feross Aboukhadijeh said at 4:37 pm on March 28th, 2011:

    @Dan – No, this does not like the Facebook ads. :)

  18. 18 Feross Aboukhadijeh said at 4:38 pm on March 28th, 2011:

    @Giuseppe – Nice improvement! Language independence is a good idea.

  19. 19 Feross Aboukhadijeh said at 4:42 pm on March 28th, 2011:

    @Ron – Sorry that you’re having trouble getting it to work. Did you drag the link to your bookmarks bar? If it still doesn’t work, tell me what browser and browser version you’re using and I’ll look into it.

  20. 20 Alan said at 12:20 pm on March 29th, 2011:

    People don’t get notifications anymore when you like their posts :(

  21. 21 Feross Aboukhadijeh said at 7:01 pm on March 29th, 2011:

    Not true. I just tested it. Maybe you’ve been doing too much Liking?

  22. 22 Ron said at 7:19 pm on March 29th, 2011:

    @Feross

    Yes I have tried that. I am using Firefox 4 on Arch Linux. I can suck it up and just use it in Chrome, because it works there. But just a heads up.

  23. 23 Feross Aboukhadijeh said at 8:24 pm on March 29th, 2011:

    @Ron Ah, that is certainly an obscure setup. I don’t know anyone who uses Arch Linux. It looks like the problem is only with Firefox. Not sure what’s causing it, but I’ll look into it.

  24. 24 Feross Aboukhadijeh said at 8:33 pm on March 29th, 2011:

    @Ron – I just fixed the bug in Firefox. You need to update your bookmarklet. It turns out that you need to end all JavaScript code within links and bookmarklets with void(0); or else the browser will try to follow the link. It should work now.

  25. 25 Alan said at 5:51 am on March 30th, 2011:

    I’m talking about using a Facebook as a page that’s yours. It works with a regular account, but not if you are using a Facebook fan page to run it.

  26. 26 Ron said at 7:29 pm on March 30th, 2011:

    Pros to you.It does work now, Thanks!

  27. 27 koska said at 5:21 am on April 13th, 2011:

    hello. Block! You are engaging in behaviour that may be considered annoying or abusive by other users.
    You have been blocked from using the like feature because you repeatedly misused this feature. This block will last anywhere from a few hours to a few days. When you are allowed to reuse this feature, please proceed with caution. Further misuse may result in your account being permanently disabled. For further information, please visit our FAQ!
    so how to hide this spam?

  28. 28 Feross Aboukhadijeh said at 1:31 am on April 14th, 2011:

    Sorry to see that you were blocked. Just wait a bit and you’ll be able to Like again. Next time, don’t go so wild with the Liking.

  29. 29 Hanush Kumar said at 12:31 am on April 20th, 2011:

    How to remove this source code, after once it has been added ??

  30. 30 alan said at 8:14 am on April 30th, 2011:

    hey dude you should make a java script that likes all check boxes

  31. 31 Lewis said at 6:25 am on May 23rd, 2011:

    Hey,
    I used this and it was great, it liked every post i wanted it to BUT… it doesn’t appear in peoples newsfeed that i have liked there comment, and thats what i need so they come to my page and see who i am etc.

    Any solutions to this?

  32. 32 Lewis said at 1:38 am on June 5th, 2011:

    Can anyone help with the post above?

  33. 33 Ben said at 6:45 am on June 26th, 2011:

    Yeh, same problem over here.. it likes the stuff perfectly.. but people don’t get notifications that their post has been commented on.. please fix, it’s an awesome bit of code!!

  34. 34 alan said at 12:43 pm on July 7th, 2011:

    you should make a java code to like all comments on a youtube video

  35. 35 Name (required) said at 1:52 am on August 20th, 2011:

    :D the java code is suuuucccckkkkk i can’t found the facebook’s javascript ;)

  36. 36 Jamie said at 12:49 pm on August 20th, 2011:

    I used a like script for exactly one click, which liked about 20 updates and I got the blocked message from facebook. How INSANE!!!!!!!!!!!!!!

    I’m using facebook for business and paying for advertising. I thought a script might help me speed up liking all my new fans posts.

  37. 37 Sanjith said at 8:41 pm on August 20th, 2011:

    Dude, tried the stuff, and got blocked by facebook for a few hours! Need to find a way to do it slow.. :-D

  38. 38 Lewis said at 4:32 am on August 30th, 2011:

    Why does it not appear on the persons newsfeed that you have liked there comment?

    Is there a way of making this happen?

    FEROSS PLEASE REPLY!!!

  39. 39 Antonio Feregrino said at 8:24 pm on October 13th, 2011:

    I just got blocked, tried to like about 800 items and that’s all.
    By the way, Feross you’re a big inspration for me, thanks a lot.
    Keep it great man!

  40. 40 Troseph said at 11:24 am on October 21st, 2011:

    Does the timeout need to be changed? I got blocked at 60 likes.

  41. 41 Antonio Feregrino said at 11:14 pm on October 22nd, 2011:

    Using part and some ideas from this script, I’ve made this:

    http://fferegrino.blogspot.com/2011/10/retweet-all-on-twitter.html

  42. 42 Feross Aboukhadijeh said at 12:28 am on October 24th, 2011:

    That’s pretty cool. Good job!

  43. 43 Virendra Rajput said at 3:37 pm on February 15th, 2012:

    Feross I just listed your I like everything Bookmarklet in http://teckzone.in/blog/2012/02/some-really-amazing-bookmarklets-for-an-awesome-browsing-experience-and-boost-up-your-speed-and-productivity/

  44. 44 Baheej A said at 10:00 am on February 19th, 2012:

    Excellent piece that is… I would also love a bookmarklet that shows me the most liked posts on a page. I mean, i should be able to see all the very important posts (most liked, shared and commented) in a page at the click of the bookmarklet. Do you have anything of that kind


Leave a Reply

Fork me on GitHub