Suggest a Page to all facebook Friends

by Christoph Menge in Software

Bulk operations on facebook aren’t too easy to accomplish and typically involve some javascript hacking. For example, there’s a number of scripts on the net that show you how to invite all your friends to an event.

However, when I want to share a page, I’d rather not come up with some kind of wannabe-event. I simply want to suggest the page to my friends.

It took me some time to figure out how to do that. The basic idea is the same – inject a bit of javascript that invokes a click() on all items, preferably using Chrome’s console. The problem is that the actual list of friends is in an IFRAME, and Same Origin Policy will prevent you from gaining access to the contents of the IFRAME.

The Solution

  1. If you haven’t installed it yet, install Google Chrome. It’s definitely the best browser for this kind of productivity boosting.
  2. Create a new shortcut to Chrome with an added command line option --disable-web-security. This will deliberately disable a security feature called “Same Origin Policy“. On my machine, the link looks like
    C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe --disable-web-security
  3. Warning: This is dangerous. Do not use this shortcut for regular browsing , but only to toggle all selected friends.
  4. Open the security-disabled Chrome and navigate to the facebook page you want to share and click “Suggest to Friends”
  5. Right-Click the page somewhere and select ‘inspect element’ to open developer tools. Choose Console
  6. Now, enter the following line:
    javascript:v=document.getElementById("social_graph_invite_iframe");var friends = v.contentWindow.document.getElementById("all_friends").childNodes;for(i=0;i<friends.length;i++){friends[i].childNodes[0].onclick()};
  7. Hit Enter in the console window to select/deselect all friends. This is nothing but a ‘toggle all’ feature the hard way.

A Detailed Walkthrough

Create a new shortcut

First, find your existing Chrome link, right-click it and select “Properties”:
A screenshot depicting the properties dialog of the google chrome browser's default shortcut with the 'target' highlighted

Select the text in “Target” and copy it (Ctrl + C).

Next, right-click the desktop and choose “New -> Shortcut”:
A screenshot depicting the desktop's context menu with new.shortcut highlighted

In the dialog, paste (Ctrl + V) what you just copied and add --disable-web-security. Mind the space character in between!

Click “Next” and enter a name for the new link, for example “Chrome (Insecure)” which reminds you NOT to use this for day-to-day browsing:

Click “Finish” and you should end up with a new shortcut on your desktop:

Applying the Javascript

Screenshots for the facebook / chrome part are coming, but that takes a little longer to ensure privacy…

That’s about it for now. Now go and share this link with all your friends :-)

Post to Twitter Post to Delicious Post to Digg Post to Facebook

No related posts.

Tags: ,

← Previous

Next →


  1. Banks says:

    How do you create a shortcut using a command line? I can’t figure it out… I obviously know how to access a command line dialog box in accessories. And I inserted the proper command line similar to the one you have as “C:\Users\UserName\AppData\Local\Google\Chrome\Application\chrome.exe –disable-web-security,” but with the location of my chrome.exe application. Didn’t work. I would be indebted and very grateful if you could help, as I have over 2000 facebook friends and cannot click 2000 times… hahahahaha…

    I apologize for being so naive…I realize this site is for those familiar with code. I am obviously not one of those people… I am a whiz in using creative software though (as end user, not creating the software, mind you), so if you help me out with this I would be more than happy to work out some sort of trade for some minor creative services…

  2. Howdy,
    Thanks for your comment!
    I’ll add a couple of screenshots to explain it better, which is probably more helpful than some longer text here…

    This post doesn’t really fit my site’s focus, good point. I think I’ll have to think about the site’s focus, after all, or maybe split it into two sections because the upcoming post is also geared towards end-users rather than developers.


  3. Banks says:

    Nice. I’d thought it was something I needed to do with a command prompt. Your screenshots were uber effective. I am sharing this post, as well as your website. Thank you so much for your time…

  4. Thanks, your comment reminded me to take those screen shots in facebook, but unfortunately my account is currently down:

    “Your account is temporarily unavailable due to site maintenance. It should be available again within a few hours. We apologize for the inconvenience.” :-/

  5. Banks says:

    I got this error message…

    Unsafe JavaScript attempt to access frame with URL from frame with URL ….

    Domains, protocols and ports must match.
    TypeError: Cannot call method ‘getElementById’ of undefined

  6. Banks says:

    If, for security concerns, I should not post that url i just did, please remove it from your comments and simply use it as a reference…

  7. Banks says:

    Thanks again for your help.

  8. Well, that error message is triggered by the “same origin policy” which should not happen with the chrome with disabled web security.

  9. Banks says:

    I figured that was the case with the “Domains, protocols and ports must match.” message.

    I’ve followed the instructions carefully, and keep getting error messages. Strange…

  10. i have downloaded chrome but i cant find properties? it looks nothing like screenshot you are showing here. please help.

  11. George Jones says:

    I’m getting the same error… even when using a non-secure instance of Google chrome with web security disabled

  12. @Maria: these are the Windows shortcut properties. Your blog has an apple logo – are you using an apple, i.e. MacOS?
    @George: I just tested this with my laptop and have tested this with two machines before. Always worked fine. However, I’m using Windows 7 on all machines. Make sure there’s two hyphens for the startup parameter. My google chrome version is 10.0.648.205. Hope that helps.

  13. ed says:

    is there a macos version of this?

  14. Tony Williams says:

    When I try and complete step one and two I keep on getting this message:
    “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe”–diasble-web-security” cannot be found

    So I cannot even continue to the next steps. This is the most descriptive and most helpful method that I have been able to find so far it’s just getting past these first two steps! Please let me know what, if anything, I can do as soon as possible; I have to create this page by Sunday (Tomorrow) afternoon!


  15. @ed: Sorry, I’m not a mac user. The procedure should be the same, basically, but I can’t provide any screenshots
    @Tony: Make sure to put the quotes right. The end quotation mark should come right after .exe, followed by a space and the parameter --disable-web-security.

  16. D says:

    Great work! It works beautifully. Too bad it appears that the suggest to friends feature on pages is much less powerful now. You used to get a notification when this occured, but now it appears that the suggestion only appears on the sidebar of a user’s home page.

  17. LauraWynn says:

    I’m an admin of a page so I do have the suggest to friends option. Everytime I click on it I get this message:

    I have tried from numerous computers under my account and I continue to get this message.

    I logged in under two other admin accounts and was able to suggest to friends without any problems.

    Can anyone help me?

  18. Jared says:

    Got the following error: “TypeError: Cannot read property ‘contentWindow’ of null”


Leave a Comment