In the rare occasion when I am trying to mass promote an event or fan page on Facebook, I always find it tedious to have to select all of my friends for the invite. Granted, I have a very good idea of who I should invite to the event or page, but sometimes I forget or assume that certain people wouldn’t take interest what I am promoting. Like anyone else, I’d much rather have the daunting task automated for me.
Facebook is constantly changing their website behind the scenes, and with these changes, old code tricks do not seem to work anymore. Fortunately, I was able to find this script and it works out great with the current version of Facebook (July, 30, 2011).
By pasting the following code into the URL box and hitting enter, this will execute a loop that will check all unchecked boxes. You can even see the process occur in realtime:
javascript:elms=document.getElementsByName(“checkableitems[]“);currentFriendClick=0;friendClickTotal=elms.length;friendClickInterval = setInterval(“clickCurrentFriend()”, 15);
function clickCurrentFriend()
{
if(elms[currentFriendClick].type=”checkbox”) elms[currentFriendClick].click();
currentFriendClick++;
if(currentFriendClick >= friendClickTotal) clearInterval(friendClickInterval);
}
Also, it’s important to check for the javascript: before elms= in the URL box. I’ve come to find that FireFox and Google Chrome strip out the declaration.
If you are having problems with copying and pasting this script, please read the update below.
When using this script, though, you must understand that when the the invite window appears to invite your friends, not all of your friends have been loaded. Facebook uses a lazy loading function to optimize performance. To ensure that you are actually inviting all of your friends, keeping scrolling in your friends list until the scroll bar is at the absolute bottom and doesn’t jump. You’ll know because your friends are arranged alphabetically by last time. Below are some visual examples of what I am trying to convey.
To reiterate, you’ll notice the scroll bar constantly moving up a few notches as you get closer to scrolling to the bottom until you reach the end of your friend’s list. Once you hit the bottom of the list, paste the provided code into the URL bar and watch the script do its thing.
I tested this using Google Chrome 12.0.742.122 and it worked flawlessly. Let me know how it works in other browsers.
Update: If copying and pasting the above text does not work, please visit this text file and copy and paste the code from it instead.
I also noticed that Google Chrome now strips out the javascript: portion at the beginning of of the code. Make sure you manually retype this back in for the script to work. Otherwise, you will be taken to a Google search result instead.

damn it doesn’t work anymore!
It should! I tested it before I published this blog. Let me check it out.
Correction: It does indeed work, but I think the text formatting throws it off. I’ll throw it in a text file and link to it on here. Thanks for catching this, Marc!
still doesn’t work. oh welllllllll!
Still works for me
First got to Mozilla Firefox’s TOOLS, then select “WEB DEVELOPER” then select “SCRATCHPAD” you will see the following screen on the page:
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text,
* 2. Inspect to bring up an Object Inspector on the result, or,
* 3. Display to insert the result in a comment after the selection.
*/
On the flashing blue highlighted line enter the following script (or copy/paste – CTRL V):
javascript:elms=document.getElementsByName(“checkableitems[]“);for (i=0;i<elms.length;i++){if (elms[i].type="checkbox" )elms[i].click()};
Once you are done, then select “EXECUTE”, then “RUN”. You should see your friends checked off, then just “SAVE” at the bottom and that’s it.
I have tried the code in Chrome and Explored and it just keeps going to a search window of sites where the code is listed….any new codes?
The code still seems to work for me? Since I notice that people are having issues, I am tempted to make a screen cast of how the process works from start to finish.
I found your problem: Chrome strips out the javascript: portion before elms. You need to add that and then it will work.
Months ago it worked fine but now it doesn’t work anymore. Damn
What browser did you try it in? It still works for me. I use Google Chrome.
I think I need to rewrite and update this article.
Thanks for the comment and the heads up!
I can’t get it to work in Chrome or in Firefox. In Chrome, it keeps doing a “search” on the javascript when I paste it into the url and hit enter… Help please!
What’s happening is that the javascript: portion is getting stripped out of the code when you paste it into the URL bar. Make sure to scroll to the beginning and place this before elms=.
In essence, the JavaScript declaration is being removed… probably to prevent hacking.
You saw copy and paste this… But where do you paste it? into the URL box or what?
Yes, into the URL box. I’ll make that more clear.
Also, when you copy and paste into the url box, please check to make sure that the javascript: declaration before elms isn’t stripped out. Google Chrome and FireFox automatically do this.
when I do that it goes to a page not found. Am I supposed to put it after the facebook url? or by itself?
By itself; clear out the URL box, and paste.
It doesnt do anything. I made sure the javascript part was in there. Are you still able to do it? I am in Chrome…
Let me check right now. I have a few events I can test with.
It still works fine for me. I am wondering that since so many people are having issues if I should just screen cast it and go from there. Also, I have a text file containing the code, too. Maybe there’s additional formatting occurring behind the scenes?
How long does it take to work? I let it sit for a few minutes because I read that it may take a while. I have like 2000 friends.
It’ll take awhile since it has to loop through all of them. Make sure you scroll all the way to the bottom of the window that pops up containing all of your friends. The window lazy loads as you scroll to the bottom until you get to the bottom of the list. The list is alphabetical. Otherwise, you won’t invite everyone on your list.
Yup, pretty sure it’s time to make a screencast. I apologize for all of the confusion.
No it works. I just tested it on a small group I custom made. And it checked them quickly. I’m going to do it on all my friends and let it sit for a while and come back. I’ll let you know. This actually works very well. Just describe more in detail that you need the pop up window open, and you need to paste it over the URL and then make sure the word javascript: is still in the front.
I made an edit in the blog post. Should be good for now. I’ll probably re-write the article at the very least. Thanks for commenting and asking questions! I appreciate it.
No worries. Thanks for posting this. Great little tool!
Not a problem! Glad it works for you!
Seems to only work in webkit browsers. Safari and Chrome. Did not work for me in Firefox or IE.
Interesting. What version of FireFox? I did my testing in FireFox 5.
Mine is 6.
Looks like you’re correct.
FWIW, it also fails in Opera.
Well, back to the drawing board, I guess. Thanks for the testing!
no problem. great website btw.
Thanks so much.. the code worked for me! i had to use the code that u posted in the “update” yay! it worked! Im so happy.. u just gave me back a few hours of my life… i was about to have to select 4200 people one by one… = )
Glad I could help someone! I am still in the process of revamping this post. It seems there’s a lot of misunderstandings and it looks like the code only works in Chrome?
Thanks for the comment. Glad I was able to save you some time!
By the Beard of Moses I just tried it, and it worked. At first it only highlighted 40+ friends then I waited and BAMMMMM!!!!!!!!!!!!!! All 1200 of my friends were selected in no time. Thanks for saving me so much time
Thanks for the excellent code. At the beginning it was not working on Chrome because I forgot to check for “javascript:” on the start, you have to manually add it every time you copy-paste the code. Real time saver, people are starting to pour in my pages
Glad you enjoyed the code snippet! I still gotta write working versions for FF, IE, and Opera. :-O
I’ve tried using this on Chrome, with adding “javascript:” at the beginning of the code and nothing happens. I have over 4,500 friends. Is that possibly the problem?
That could be. I’ve tried it with roughly 1,600. I’m pretty sure there is a comment on this post that stated at least a few thousand. I’ve recently used the code (last week), and it still worked like a charm for me.
Did you scroll all the way to the bottom of your friends list so that the lazy loading feature loaded all of your friends? Also, did you scroll back up to the top of your friends list to make sure the script started? Just checking the basics, just in case
not sure why but it just worked one time. i closed and re-opened the browser a couple times. who knows.
bottom line: thank you.
Odd. Thanks for letting me know, though!
You’re welcome.
Code worked but Facebook is giving me the error that I need to narrow my selection… and then not sending the invites out. Any suggestions on that?
It says.. the following EXACTLY….
Can’t Send Invite
Please narrow your invite list to friends who are most likely to be interested in this event.
If you’ve gotten this message in error, visit this form.
Sorry for the late response on this one, Becky.
What happens is that Facebook doesn’t like when you invite an X percentage of people on your friends list. It’s sort of their way of combatting spam and mass invites.
What I do is that I go back and uncheck people that I know won’t attend the event/page, and that seems to help.
I have also noticed that even if the error does pop up, it still goes through and works.
In chrome, Google search engine result appears for above script. Didn’t work for me.
Fail.
Finally, I tapped Tab and spacebar and selected all my friends, though frustrating but could select all of them in 8 minutes
@nicks25 on twitter
Good thinking! It works, but is still faster than manually checking everyone.
The reason why the script gave you a Google search result is because you may have forgotten to add “javascript:” as that part of the code gets stripped in the URL bar.
Downloaded chrome , won’t work , firefox , won’t work , IE won’t respond ….manually added javascript: ….when I hit enter it just goes back to the original FB url like I never put anything in . I have 5k friends , but clicked about 1k away thinking that may help , nope , back to clicking
In chrome, did you make sure the text “javascript:” was present before the elms declaration? Chrome strips out the aforementioned text, so it needs to be added after you paste the code and before you hit Enter.
Worked great on safari, thanks!
Thank you Brett Widmann! Worked like a charm on chrome v18.0!
I’m extremely inspired along with your writing abilities and also with the format in your blog. Is that this a paid subject matter or did you customize it your self? Either way stay up the nice high quality writing, it’s uncommon to look a great weblog like this one these days..
How much time would it take?
Yes it works, finally thank you. YOu need to put the javascript at the front, and wait a few seconds. I thought it wasn’t doing anything at first, but it takes a little while to tick all the boxes on the list
You can use this Chrome Extension, this more easy:
http://chrome.google.com/webstore/detail/facebook-invitethemall-fo/jladghljinmlokelojmdmblikkifabea
Thanks for the heads up on this!