Ash Clarke

Software Engineer. User Interface Developer. Gamer. Nerd.

How to Hide Facebook Ads in Mozilla Firefox with Stylish

| 12 Comments

Ads. They suck. You never click them and they don’t benefit your life whatsoever.

If this sounds like you, I will now let you in to a secret way of hiding them that no company ever wants you to find out…

Not really, it’s just CSS styles. First step is to download the Stylish add-on for Mozilla Firefox.

After you have installed the add-on and restarted Firefox, visit Facebook.com.

In the bottom right corner of Firefox, there will be an S icon.

Clicking this will open up a menu, where you can choose to “Write a New Style”. Click the “For facebook.com” option.

This will bring up a new window where you can enter your new styles to override the Facebook developers’ defaults. I have added a screenshot to show where the new styles go.

Now you can replace the text in the window with the following rules:

@namespace url(http://www.w3.org/1999/xhtml);

@-moz-document domain("facebook.com") {

/* Updated 12-02-2012 */

/* Hide ads on Home */
#rightCol #pagelet_ego_pane_w { display: none; }

/* Hide Right Column Footer on Home */
#rightCol #pagelet_rhc_footer { display: none; }

/* Hide ads on Timeline and Photo View */
#rightCol #pagelet_side_ads.fbTimelineSideAds,
#rightCol #pagelet_side_ads,
#fbPhotoSnowliftAdsSide { display: none; }

/* Hide ads on Comment View */
.UIStandardFrame_SidebarAds #pagelet_ego_pane .ego_column:not(.egoOrganicColumn) { display: none; }

/* Hide "People you may know" on Comment View */
.UIStandardFrame_SidebarAds #pagelet_ego_pane .egoOrganicColumn { display: none; }

/* Hide ads and sponsored stories on Message View */
#MessagingNetegoSidebar #pagelet_ego_pane .ego_column:not(.egoOrganicColumn) { display: none; }

/* Hide ads on pages */
#rightCol #pagelet_ego_pane .ego_column:not(.egoOrganicColumn) { display: none; }
}

Click the “Preview” button and you should see the ads disappear in the background. Click “Save” and the window will close. The styles will now be loaded when you visit any part of Facebook.

Let me know if this doesn’t work, or stops working. The styles above are heavily dependent on how Facebook developers have named the Ad elements on the site.

If they, therefore, realise another lovely update the ads might suddenly reappear and I will have to spend another 30 seconds writing a new style and 10 seconds updating this post : )

If you feel you can’t trust this, or it looks like something messed up, you can find the “Uninstall” (to remove it) or “Disable” option by right-clicking on the style when visiting Facebook.

UPDATE: Added styles to hide new ads on the new timeline profile.

UPDATE [02/11]: Updated with new css to reflect recent code changes by FB devs.  Thanks, “R Preston Berrett”.

UPDATE [02/12]: Updated with new css to reflect changes to the FB site. Added better comments to explain what each bit is doing.

UPDATE [02/12]: Updated with new css to hide ads on “pages”. Thanks “J Greener”.

Author: Ash Clarke

I am a user interface developer based in central Reading.

12 Comments

  1. I've been using this for over a month now, and it has been working perfectly until today, when I noticed that the ads are back. I spent about 15 minutes trying to figure out how to do it myself, but figuring out the syntax is a little difficult than I thought it would. Would you mind updating the post? Thanks!

    • I've put in a quick edit – hopefully that will do the trick! Let me know.

      • Yes, that did the trick.
        So, I'm a Computer Science major in school right now. And last night I took a swing at modifying the script, and got as far as removing the ads from my home page. But, this morning I noticed that my edit did not remove the ads when I visited a friends page. Again, thanks for this.

  2. Pingback: How to Hide Facebook Ads in Google Chrome with Stylish | Ash Clarke

  3. Ashley. You are my hero. You make bad ads go away. Ads can get very irritating when I'm on the Facebook looking for hot penguin ladies. Facebook ads make me even more evil than I am most of the time. Seriously – I do awful things.

    All the best, and keep up the good work, Mr C. If the ads re-appear, I'ma comin' for you….

  4. The ads are back. You're dead.

    • You'll have to say which page and what section because each part is different :)

      Then I can add the code in with the rest.

      Thanks!

  5. Hi Ash, will these fixes (and thank you!!) hide ads when others view our business page?

    • Hi "J",

      Just checked and it wasn't so I have just updated with another line to hide ads on pages.

      Hope this helps!

  6. Hi “J”,
    I’m pretty sure they will as Facebook pages typically follow the same layout.
    I will check during the weekend and make sure.
    Thanks!

Leave a Reply

Required fields are marked *.

*