How to invite all your Facebook friends to an event at once (code has changed)


In the last few days, Facebook has changed the “invite your friends” functionality, which powers suggestions and invitations to events, groups, pages, etc.

The result is that old Javascript codes that allowed you to invite ALL your Facebook friends to an event in a snap (such as this) are now broken.

To select all your new friends in the new interface you can use this code, tested under Safari 5.0.4, Chrome 10 and Firefox 4 (should work also under IE).
UPDATE: There are many reports of it working on newer versions in the comments below.

javascript:var x=document.getElementsByTagName("input");for(var i=0;i<x.length;i++) {if (x[i].type == 'checkbox') {x[i].click();}}; alert('Done, all your friends have been selected');

In order to use this code, copy and paste it in the address bar of your browser after you have opened the “invite your friends” dialog and AFTER YOU HAVE SCROLLED DOWN THE LIST.

Important note: as said, you HAVE to scroll down your friends list in order to invite all your friends: in fact the new interface only loads few friends via AJAX at a given time.

Facebook should definitely be a little more open regarding MY data, loaded on their systems… and this script opens it just a bit more.

DISCLAIMER: I DO NOT ASSUME ANY RESPONSIBILITY WHATSOEVER FOR THE USAGE OF THIS CODE; IF YOU GET BANNED BY FACEBOOK, OR ANYTHING ELSE, YOU WILL BE CLAIMED THE SOLE RESPONSIBLE FOR SUCH ACTIONS.

  1. #1 by Jr on 04/04/2011 - 03:52

    This does click the check box element however it does not actually select the actual element.

    in essence they appear to be checked but are really not.

    I am trying to play with the different elements to get this to work properly.

    Excellent script, any thoughts on how we can get it to click the actual element to make it work?

  2. #2 by Marco on 04/04/2011 - 10:00

    You are right, there was a minor glitch.
    Now it should work properly, at least for me it did!

  3. #3 by JR on 04/04/2011 - 13:52

    Well done Marco, I too did a similar piece of code based on your original js.

    javascript:var jt=0; var x=document.getElementsByTagName(“input”);for(var i=0;i<x.length;i++) {if (x[i].className == 'checkbox') {x[i].click(); jt++;}}; alert('executed on ' + jt + ' objects');

    Thanks for the inspiration!

  4. #4 by Nick on 06/04/2011 - 19:24

    Hey guys,

    thanks a lot for putting this stuff up. It will be really helpful if I can work out the kinks I’m having.

    I’ve tried JR’s code, but nothing happened. Conversely, when I do yours, Marco, it works, but only invites like a fifty or a hundred people at a time (haven’t counted). Could you guys tell me if I’m missing something? I don’t know anything about this, I’m just an author who is touring who invites all my social network friends to the events to let them know where I’m at and what I’m up to.

    Thanks a lot,
    nick

  5. #5 by Nick on 06/04/2011 - 19:25

    maybe just wasn’t scrolling enough. d’oh! i think i’ve got it now. thanks a lot, guys.

    nick

  6. #6 by Marco on 06/04/2011 - 19:43

    Yes, you need scrolling down and possibly repeat: friends are loaded by AJAX and are inserted in the DOM of the page only after you scroll the list completely.

  7. #7 by Donald O'Donovan on 08/04/2011 - 00:27

    Thanks a million, bro! I’ve been struggling with the old code for more than five hours with no result. I’m bookmarking your page and will continue tomorrow (can’t face more today, and I have…oh, yeah…other work!) But this will be a life saver if I can figure it out because I need to reach the PEOPLE and I don’t really know a lot of computer stuff. Thanks!

  8. #8 by chris on 11/04/2011 - 01:38

    none of the codes work for me WTF PLEASE HELPPP

  9. #9 by Marco on 11/04/2011 - 09:01

    Saying “doesn’t work” doesn’t help at all.
    Could you debug the JS? If not, could you send in to my email the *generated* DOM you get when clicking on the FB “invite friends” button?

  10. #10 by Molly on 12/04/2011 - 00:02

    Hey thanks for the help. I am waiting right now for facebook to recognize the code. I waited for all my friends to load – 4,500 and now am waiting to see if the code works. It’s been like almost 5 minutes and nothing has happened. How long should I wait?

  11. #11 by Molly on 12/04/2011 - 02:15

    Thank you! It worked in a different browser and thanks to you, Marco, I just invited over 4,000 friends to watch me on the tv show, Wipeout, this Thursday, April 14th!

  12. #12 by Amy Jo Neal on 12/04/2011 - 17:53

    Thanks Marco! I’ve been searching for an update of the old script and widget since FB deactivated them. My 9000 fans will be so happy to know now that I’ve posted it on my wall. You rock!

    Cheers,
    Amy
    “The Marketing Lioness”
    http://facebook.com/ILikeAmyJoNeal

  13. #13 by Joe on 15/04/2011 - 19:09

    Still works!!! :-) Got stuck on google chrome, but was ok on mozilla

  14. #14 by andrew on 19/04/2011 - 00:51

    tnx

  15. #15 by rcj66 on 23/04/2011 - 17:55

    Hey guys…anyone know if there is something similar for a fan page? where i can invite friends to “like” my page? thanks!

  16. #16 by adil on 24/04/2011 - 01:38

    how do i do this with a group?

  17. #17 by Marco on 24/04/2011 - 11:22

    You can’t do this with a group: Facebook has removed the functionality to invite anybody to groups. I suspect that some very near day in the future groups will become pages automagically.

  18. #18 by Jon on 25/04/2011 - 07:09

    doesnt work properly. after you scroll down to select more friends, the friends above get deselected…

  19. #19 by Marco on 26/04/2011 - 08:29

    @jon, it’s strange. Have you tried scrolling down the list of friends BEFORE starting the Javascript?

  20. #20 by grant on 26/04/2011 - 23:39

    Does anyone know how to message more than 5000 from an event?

  21. #21 by richard on 01/05/2011 - 19:48

    HI The code is working fine but now when i press ok it saids that i cant send invites that i just can send invites ti my closest friends who are intersted in the event ….
    and they ask me to fill a form any idea how i could avoid that ?

  22. #22 by Mocker on 03/05/2011 - 14:55

    It works on Safari. Very long (1700 friends) but it does work in the end. I confirm this point, you have to scroll all the way down your list, before pasting the script.

  23. #23 by Anup Singh on 08/05/2011 - 11:47

    Awesome work Marco! and the rest of the guys supporting him…
    This is working on Safari
    And I have to say – Kudos and respect for you!
    Thanks a million…this is also on behalf of most others who use this code, but never bother saying thanks…
    PS. You have to scroll down when you click invite, so that all your friends are on the screen! then paste the script – and hit ENTER!

  24. #24 by DesignByCG.net on 10/05/2011 - 05:33

    WWWOOOWW!! YOU ARE AMAZING! Thank you soo much!

  25. #25 by Vasco on 15/05/2011 - 00:06

    Thanks! Works fine!

1 2 3 27
(will not be published)