Ad Blocking

I can't stand ads. Yes I know they're necessary and they're the only reason why a lot of sites even still exist. But that doesn't mean I have to like them. Here are some of the steps I've taken to block ads with Mozilla.

Disable Popups

I still laugh at people who complain about popups. Silly IE people. In Mozilla, go to Edit | Preferences | Advanced | Scripts & Windows and uncheck "Open unrequested windows".

There, no more annoying popups.

Block Images from this Server

I used to use the blocking ads with a hosts file method, but I would get a "server not found" alert box message every time I hit an ad that was blocked in the hosts file. So of course the solution was to use Mozilla's built in "Block Images from this Server" command.

Now when I see an ad, I right-click on it and select "Block Images from this Server". Hit refresh and the ad is gone. There's a satisfactory feeling when you add servers to a black list, kinda like the feeling you get when you cross off items on a to-do list.

A warning though: a good idea is to first right-click on the ad and select Properties. If the ad originates from an ad server such as then you can go ahead and block it. I mention this because some ads aren't served from ad servers but from subdirectories of main sites. For example, the banners at Slashdot are hosted on If you tried blocking it, it would block the entire domain and therefore all images on Slashdot would be blocked.

"Block Images from this Server" only blocks servers and not subdirectories. There's a bug entered in Bugzilla about this. Vote for this bug!

You can view the list of blocked image servers from the main menu.

In previous builds:
Tasks | Privacy & Security | Image Manager | Manage Image Permissions

In latest builds:
Tools | Image Manager | Manage Image Permissions

Unfortunately the Image Manager only allows you to view and remove ad servers. You can't manually add new ones here. If you would like to manually add or edit servers, you have to edit the file where all the blocked servers are stored. This file is called cookperm.txt and is located in your Mozilla Profile directory, which on 2000/XP is usually here:

C:\Documents and Settings\User\Application Data\Mozilla\Profiles\user\*.slt

As an addition, I went to this blocking ads with hosts files site, downloaded the txt file of their updated list of ad servers and converted it into the format Mozilla uses in the cookperm.txt file.

Here it is: cookperm.txt

If you shut down Mozilla and save it to your profile directory, it should then block all the banners from those servers when you restart.


The only bookmarklet I use is Zap created by John Weir of Zap removes underlines from links, images, and all iframes. I usually use this bookmarklet on pages with the really annoying Flash ads, or on "Printer Friendly" pages that aren't really printer friendly. For example NYTimes likes showing a giant Starbucks ad along the right side on their printer friendly pages. Zap kills it.

Mozilla Addon

Banner Blind is a mozdev project that can hide banners from any website. It basically works by blocking all common banner image sizes such as 468x60. So, this type of config may block images that aren't banners if the file sizes match a commonly used banner size. The config screen allows you to enable/disable BannerBlind. It also allows you to customize which sizes to block, as well. I've been using it for the last few days and it works pretty good.


If you have any other tips, let us know! And please let me know if you have any problems with the cookperm.txt file. I've only tested it on my w2k box.

» posted by pinder on April 10, 2002 at 05:25 PM


I used your cookperm.txt file on a fresh Windows XP Home install with Build 2002031104 of Mozilla and it worked perfectly. Thanks for your hard work!

# posted by Jason

For those not so fussy like myself, just setting the images privacy & security setting to only accept images from the originating server, pretty much blocks out most ads, and not too much else - nothing I'm missing in the sites I visit anyway.

# posted by Dean

But where are you going to go when the free sites funded by all that advertising have closed down or started to charge? Pop ups really bug me, but reasonable amounts of banner advertising (ie - less than yahoo groups) are OK.

I reckon we have some sort of duty to look out for people who provide us with good free content.

What about an option to re-enable banner ads for "friendly" sites? ie. "serve all images requested by sites in this list"

Just a thought.

# posted by Paul

Ad blocking doesn't work when an onLoad is in an <img> tag, as I discovered on the New York Times web site, the only one I had found that could spawn popups. Evil.

Needless to say, I submitted a bug:

# posted by Joe

The Preferences Toolbar created by Aaron Anderson is a very cool way to let you turn on and off things like whether to run javascript, allow popups, load images, etc. Much nicer to toggle there than to dig down in to prefs to toggle settings.

# posted by Jeff Wilkinson

Hey, I just checked my Documents And Settings folder and I couldn't find the cookperm.txt file there, how would I now use it to tell which sites to remove banners from ? I have installed the program correctly, bannerblind that is :)

# posted by Mr Damian

Try using this Hosts file [ ], possibly the most comprehensive (14,000 verified servers!) i have ever seen , makes the ones linked seem rather miniscule, and you can upload your hosts file if you already have one to contribute, heh dont you just love open source :)

# posted by John Stevens

The actual Mozilla file is cookperm.slt, not .txt.

# posted by Alan

If you can't find cookperm.slt or cookperm.txt as it is called at my computer, the folder "Application Data" might be hidden. Go to "My computer", choose "Tools - Folder Options" and select "Show hidden files and folders" (Windows 2000).

# posted by George

I highly recommend Privoxy, formerly Internet Junkbuster, available from It works as a proxy server, rewriting web pages to remove ads and much more. In combination with a hosts file (and eDexter, a trivial local-only web server, to fill in the blanks), I hardly see non-text ads at all any more.

# posted by Lionel Hutts

Vote for bug 33576! Vote for bug 33576!

Just like pinder recommends. IMHO, this would be great if this bug was fixed and we had more advanced options to block images within Mozilla itself as it says in the bug's comments.

1. Go to

2. Just above the Additional Comments text window, you'll see "Vote for this bug".

3. Click on that link and vote for that bug so that the dev team will hopefully work on it more.

Down with ads! I'm all for websites being free because of these ads, but I think I should also have a choice if I want to see them or if I want to block them. : )

# posted by Pravoslavnie

To Pravoslavnie: Then sites that cover their costs with ad revenue should have the choice of whether they want to disallow access to grifters using ad-blocking techniques.

# posted by James

how can one block flash ads with moz?

# posted by joShua

Blocking flash ads would be wonderful, but in the meantime, just don't install the plugin. You won't miss much, and it stops pages from being taken over by speeding SUVs and other buzzy annoyances.

# posted by Lemming

Until there is a way to block Flash animations, it is best just not to install the damned thing. Flash is useless, anyway -- no decent web designer builds a site based on Flash, anyway, just goofy high-school kids who are apparently color-blind or high on X (or both).

So just delete Flash until Moz has Flash-blocking. You won't miss anything worthwhile.

# posted by Brandon Blackmoor

You can block flash ads in Mozilla, with userContent.css! :)
Works with the conventionnal banner sizes.

# posted by michel v

I hope mozilla or banner blind ads flash blocking support soon. I hate flash ads. they're the only ones that get by my filters.

# posted by BobbyT

I wish netscape did this. I think the only reason I use netscape is because I can get my netscape mail. And the 128 bit security is included.

# posted by freecia

Why not use Automatic Proxy Configuration to block ads? The browser passes all URLs through a JavaScript function that will decide what proxy to use for the request. You can set the default to go to the site directly, but URLs matching your ad criteria instead go to a proxy that serves up transparent gifs. A friend has a writeup of how to do this at

# posted by Preston

Those Flash comments really are asinine. While i love good plain, old HTML coding, there's plenty of good Flash work out there. You're obviously just not seeing it (or not realizing you're seeing it).

# posted by jessie

Here's a weird problem - when blocking ads in Mozilla, I use Yahoo a lot, and saw a banner. I tried to block it, but It acted like it was already blocked. Searching through the HTML source I noticed that the ad's URL was:

but it got re-directed to

I had in my cookperm file, but

I had to manually add the latter to cookperm to block the image.

# posted by ron

To block flash advertisements and still retain the ability to view choice material when desired, check out this on/off flash switch utility program:

Its called jTFlashManager

# posted by Alan

not specifically a mozilla bookmarklet, but you might dig on the linkworld bookmarklet, for browser- and computer-independent bookmarking:

# posted by jm3

FYI, the problem with the "server not found" errors when using the host file method was only in a few versions of mozilla, and it appears to have been fixed (should be, I filed a bug on it :-). It also might depend on if you map the ad server to or

In any case, I use a hosts file to map ad servers to and with Mozilla 1.2.1 I get no annoying pop-ups or anything. Nice thing is that it works with all programs on your OS (i.e. Phoenix, Galeon, IE, etc), so it's not a Mozilla specific feature.

# posted by Pete

Check out my use of CSS3 selectors supported by mozilla and NS7. I use it to block ads based on substring matches in the href of a link for links that contain images. I find that matching on the link href is more reliable than matching on the image src.


# posted by joe

Use CSS3 selectors to block ads :
Ok, ads are not display, but there are still loaded...

# posted by Domi

update your site (or is it still alive) ->Disable Popups

In Mozilla, go to Edit | Preferences | Privacy & Security | Popup Windows - uncheck "Open unrequested windows".

# posted by daimon

The following batch (adjust according to where you put mozilla) will turn SHOCKWAVE off and ON. I attached a shortcut to it on my desktop. Now I can turn SHOCKWAVE on to visit a site I want to see, and I can turn SHOCKWAVE OFF for the other 99% of the time when it's just animating, noisy GARBAGE. Like ads.

@echo off
if exist "C:\Program Files\\Mozilla\Plugins\NPSWF32.dllxxx" goto Enable
ren "C:\Program Files\\Mozilla\Plugins\NPSWF32.dll" NPSWF32.dllxxx
goto Exit
ren "C:\Program Files\\Mozilla\Plugins\NPSWF32.dllxxx" NPSWF32.dll

# posted by Evildave

Not to get into some sort of flame war, but to jessie:
I do not consider Lemming's or Brandon's comments about Flash to be asinine. I have never installed Flash in Mozilla/Firebird and have not noticed any real loss of content. I can think of one or two sites that would not work, but those sites contained no content of value, and would probably not be worth navigating the flashy (sorry) Flash menu to use. I consider Flash to be a fairly poorly constructed third party plugin. Sure, you can make some nice Flash movies in it, but there's no configuration, no option to disable it, it's not particularly cross-platform, and it can be used in highly intrusive ways. As added bonuses, with the exception of Flash movies, which cannot really be done in HTML, Flash takes longer to download than a more functional, readable, and easier to use HTML equivalent (such as a menu or even a banner). While Brandon is wrong that "just goofy high-school kids" use Flash to make websites, he is right that no decent web designer would build a site based on Flash, because it is just not worth the effort when the benefits are weighed against the negative aspects. On a side note, if I really want to see a Flash movie, I load up Internet Explorer to go watch it. This may not be a preferable choice for some people, so I would definitely be for an easy way to disable Flash at will in the browser.

# posted by Chris

In re: all ads

If you've got DSL, you can set the "parental Controls" portion of your ISP's settings page (i.e., homeportal, control panel, etc.) to block adservers--including those which supply flash animations.

I would imagine that this would work with any freeware (or otherwise) off-the-shelf- net nanny program.

# posted by Trinix

Since nobody has posted this plainly (there was one cryptic mention of userContent.css) here is how to block Flash ads, quickly and painlessly:

Create the file userContent.css in your user chrome directory. On Mac OS X, this will be in ~/ Library / Application Support / Chimera / Profiles / default / (salt).slt / chrome. "Salt" will be a random 8 character string of characters. On Windows the user chrome directory can usually be found here: C:/ Documents and Settings / (user) / Application Data / Mozilla / profiles / default / (salt).slt / chrome

Note that "Application Data" is a hidden folder. You'll have to turn on the Windows Explorer preference that lets you see hidden folders in Explorer: Tools -> Folder Options -> View -> Show hidden files and folders

Put the following in that file, restart Moz, and poof, no more annoying Flash banners! The best part is you can continue to use Flash to browse great stuff like this:

/* hide 468x60 banners */
embed[type="application/x-shockwave-flash"][width="468"][height="60"] {
display: none !important;
visibility: hidden !important;
/* hide 728x90 banners */
embed[type="application/x-shockwave-flash"][width="728"][height="90"] {
display: none !important;
visibility: hidden !important;

# posted by Carch

"yea- we do that."

# posted by rue

There is a way to block Flash if you use Firebird. Downlaod an extension called "Flash click to play". All flash boxes will look like unloaded images with text saying FLASH - Click to Play. If you want to see it, simply click on the box and it will load.
Usign firebird I can't find any form of cookperm. I searched my whole HD. Only loading images from the parent server seems to cut most all of the ads though.

# posted by Chris

Mishka rules !

# posted by Mishka

Boris rules !

# posted by Boris

I need to know how to block certain websites like Lava Life and so forth

# posted by Clayton Denny

you are too good.i share concern as yours .i am doing adbusting as my college project.we want to do it java n make it browser independent software.please help me out.we don know how exactly to proceed

# posted by ashwin

Hello. I just wanted to give a quick greeting and tell you I enjoyed reading your material.

# posted by Atkins Diet

Post a Comment

This discussion has been closed.