Helpdesk
Adblock for Mozilla Firefox
This page discusses the usage and capabilities of the powerful Adblock add-on for Mozilla Firefox.
Top Introduction to Adblock
What is Adblock?
Adblock is a simple add-on for Firefox which is primarily designed to remove content related to advertisements, such as banners, popups, images and iframes. However, Adblock can also be used as a generic blacklist application for any web content including images, flash videos, java applets, iframes, javascript files and so on.
The benefits of using Adblock, and the risks of browsing without it.
Adblock offers a few very important benefits that address a number of concerns beyond mere convenience and appearance. Most users are unaware of the dangers, both related to privacy and security, that many embedded advertisements introduce. The majority of advertisements are not simply an embedded image, but a series of scripts and tracking applications that record your browsing habit's and resell the information to the highest bidder.
These scrips can record and track a large percentage sites you visit, as well as which pages in each site you are viewing. In some cases, they can even view personal information such as email addresses, account numbers or user IDs due to the query strings appended to the URL.
In addition to recording your browsing habits, there have been many cases where embedded advertisements have contained malicious scripts that target browser or plugin vulnerabilities giving them (in worst cases) full control of affected systems; including introducing and infecting them with viruses, spyware and other harmful applications or employing them in large botnet organizations which can be controlled by the group's creator.
One of the most recent cases as of this writing, was the large scale myspace related mass infection of thousands of computers via malicious code in their embedded advertisements. Most websites don't have control over the content of their ads, they are just given a series of links to embed and the content is handled by a third party. This lack of control prevents even legitimate websites from ensuring that only clean and non-malicious advertisements are loaded through their page. View Article (Washington Post)
The majority of these malicious advertisements will not affect Firefox due to the secure way it handles content. However, there have been some cases where the exploit took place in a plugin or the operating system's handling of certain file formats which affected any Windows based machine, regardless of which browser was used. By using Adblock, you can prevent these advertisements from even loading. Advertisement networks won't be able to track you, obtain any information about you, or resell the data to a third party. Harmful and malicious code embedded in advertisements won't affect you since it won't even be loaded. Pages will also load faster then normal, since additional connections to load the embedded content from the advertising networks will not occur.
How does Adblock work?
Adblock works on a simple blacklist system. A blacklist is a text based list of matches that will be blocked. Adblock will block any items contained within the blacklist. Each item on the list is called a "rule" or match pattern. Most of the rules within the list are domains that exist to serve and host advertisements, such as adbrite.com, advertising.com etc. Many blacklists also contain rules to specifically block common ad-related directories, such as /sponsors or /ads.
Adblock Plus (the version used in this tutorial) supports two types of blacklists: a static list, and a subscription based dynamic list. With a static list, rules are ether entered by hand, or imported (as described below) and will not change unless the user chooses to alter or update them. A subscription based list reads the rules from a remote server and is updated automatically. This tutrial only discusses the static list option. (For an explintion, see my note below)
Wildcards can also be used (*). A wildcard is a "match-anything" character which is used to greatly increase the effectiveness of a rule. Instead of manually adding a rule for every ad-based image from a certain domain, you can simply use a wildcard to create a rule that blocks everything from that domain (*domain.com*). Or, you could use wildcards more specifically to block only images from that domain (*domain.com/*.jpg).
On a fresh installation, Adblock has a blank blacklist. You can add any rules you choose to block any arbitrary domain, image, iframe etc. The more rules that are added to the blacklist, the more effective Adblock will be.
Note: For a more detailed explination of the inner-workings of Adblock, see the Author's internal FAQ page.
Top Using Adblock
First be sure to obtain and install Adblock: Download Adblock
If you need instructions on how to install an add-on, you can read my tutorial.
There are two ways that you can use Adblock:
Option #1: Using Techie PC's pre-compiled blacklist.
This is the recommended method for users new to Firefox, or those that just want Adblock working immediately. I have made public a list that I have compiled myself. You can simply import the blacklist and Adblock will start blocking ads immediately.
The initial list took approximately one month to build. I spent that time visiting many of the most popular websites, such as youtube, yahoo, download.com, various news sites, game sites, social networking sites such as myspace and facebook etc. to gather a list of the major advertising domains and common ad-related phrases.
I have tailored this list to block approximately 95% or so of all standard embedded banners, iframes, flash videos and image advertisements. I have taken every precaution when constructing this list to help reduce the chance of false positives and blocking legitimate content. If you ever notice legitimate content getting blocked, either temporarily disable Adblock, modify/remove the offending rule, or contact me so I can correct it.
Jump to: Using Adblock with Techie PC's blacklist
Option #2: Building your own blacklist from scratch.
The alternative to simply importing a pre-compiled blacklist, is to write one yourself. I would only recommend this method for advanced users, or those that are curious about how Adblock and pattern matching works.
I have written a tutorial below which describes in detail the process of manually adding, modifying and removing rules within Adblock. As well as a brief coverage of wildcards and pattern matching.
Jump to: Building your own Adblock blacklist
Top Using Adblock with Techie PC's blacklist (Recommended)
First be sure to obtain and install Adblock: You may download it here
There are 7 steps required to setup Adblock using Techie PC's pre-compiled blacklist.
- Install Note: Once Adblock is installed, it will display a list automatic subscriptions. If you prefer, you can use one of the subscriptions in the list, although this tutorial is specifically written to use Techie PC's blacklist. Do note that I don't provide support for third party lists as I have no control over their content and cannot resolve issues relating to false positives.
If you want to use the Techie PC blacklist, click Cancel. [Show]
- 1: After installation is complete, you will see it's icon on the top right hand corner of the toolbar. [Show]
Note: By default Adblock installs into the toolbar. I personally prefer using it from the status bar as I like to keep my toolbar clean. To move the Adblock icon to the status bar, right click the Adblock icon, then under the Options menu check Show in status bar, and uncheck Show in toolbar. The steps below can be followed regardless of the icon's location. [Show]
- 2: Right click the Adblock icon and click Preferences. [Show]
- 3: This will open the Adblock Preferences window. [Show]
- 4: From here you can add any rule that you choose. Since we are going to be using a pre-compiled blacklist, instead of typing in a rule by hand we will import the blacklist file. Download the blacklist file here: Adblock.txt
When you click the link, you will be prompted to download a file; choose Save to Disk. It is recommended that you download the file to your Desktop, or My Documents directory unless you are familiar with navigating through the filesystem. [Show]
- 5: Once the download is complete, from within the Adblock Preferences window, click Filters -> Import Filters. [Show]
- 6: This will open a window asking if you would like to overwrite the current list with the new filter, append the filter to the current list, or cancel.
Since we do not have any rules defined in our list I recommended choosing Overwrite. It's usually good to get into the habit of choosing overwrite when using Adblock, especially if you plan on updating the blacklist file periodically. Otherwise, the same rules would be applied multiple times leading to many duplicates. [Show]
- 7: Click OK. The blacklist is now applied and active. You can confirm that by looking at the main Adblock Preferences window. You should see approximately 190 entries in the list with the words #Public1-BeginList# at the top. [Show]
- Disabling Adblock: If for any reason you need to disable Adblock, you can do so by right clicking the Adblock icon, then unchecking Enable Adblock Plus. The Adblock icon will then change to gray. While disabled, Adblock will not block or remove any content on sites you visit. Firefox will behave as if Adblock is not even installed. All ads, images, domains, content etc. will be displayed as normal. This is helpful if you want to ensure that Adblock is not inadvertently blocking legitimate content (by loading the problematic page with Adblock enabled, then disabled and see if it resolves the issue), or if for any reason you need to visit or interact with advertisement related content. (Such as configuring your google adwords account). [Show]
While Adblock is disabled, it's icon will be grayed out. [Show]
To re-enable Adblock, simply right click the Adblock icon, then check Enable Adblock Plus.
Top Building your own blacklist from scratch
First be sure to obtain and install Adblock: You may download it here
There are 4 steps required to block an element.
- 1: Once Adblock is installed, you will see it's icon on the top right hand corner of the toolbar. [Show]
Note: The images in this tutorial will be using the Adblock icon from the status bar. If you right-click the Adbock Icon, goto Options and check Show in status bar, it will be added to the status bar at the bottom of the window. The steps below can be followed regardless of the icon's location.
- 2: Right click the Adblock icon and click Preferences. [Show]
- 3: This will open the Adblock Preferences window. [Show]
- 4: From here you can add any rule that you choose. Let's add a sample rule to block all content (including images) from google; don't worry it's only temporary. There are a few ways we could block content from the google website, we could specify the full URL http://www.google.com. However, images and content are located in a directory from within the google.com domain, therefore they would still be loaded. We could explicitly define the full URL to the main logo such as:
http://www.google.com/intl/en_ALL/images/logo.gifHowever, only that specific image would be blocked, not all content from the website. We want our block to be more inclusive. To do so, we will employ the use of wildcards: the asterisk character *. A wildcard is used to block zero or more occurrences of any character. Using this technique, we can effectively block all of the content from any google page using the following rule without the parenthesis: (*google.*).
Click Filter -> Add Filter (or hit Insert on your keyboard), then type that rule within the field and hit the enter key. The rule will now be appended to the filters list. Now, when you access google.com, all images (including the logo), scripts and iframes will be removed. Any content will also be removed if it is embedded from google's website into another site that you are currently viewing. [Show]
False Positives: In our example rule there is a period before the last asterisk. This helps prevent "false positives", i.e. blocking more then what you expect, or what you didn't expect. By using the above example, this will help prevent blocking everything that so much as even mentions the word google, such as an image, or directory on a different server. Unless there is a directory or file which exactly contains (google.) Adblock won't touch it. An example of a false positive using the above rule is an image at the following URL: http://www.sampledomain.com/images/google.files/logo.jpgAs you can see, because the pattern (*google.*) exists in the URL, it matches our rule and will be blocked. In most cases when adding rules, you learn how to best avoid false positives through trial and error. If you decide to import my Adblock Blacklist, most of the rules are too specific to ad-related sites so that very few false positives should occur. Either way, if too many false positives are occurring, you can always adjust/remove any offending rules in the list to reduce the problem. If you find any false positive rules in my list, feel free to contact me so I can correct it.
Blocking Additional Elements.
You can follow the above procedure to block any domain of your choice. If however, you wanted more specific blocks, such as blocking only javascript files from a site, you can do so by modifying the above example. To block only javascript files from the site advertise.com, use the following rule: (*.advertise.com/*.js). This will cause Adblock to filter out only javascript files (ending in .js) from the domain advertising.com. All other content from that site will be loaded as normal.
Here are some additional example rules for blocking different element types:
To block all images from domain example.com:
*.example.com/*.jp*g
*.example.com/*.gif
*.example.com/*.png
To block content from the directory /ads/ from domain example.com:
*.example.com*/ads/*
To block html and htm files from the hostname ads of the example.com domain:
*ads.example.com/*.htm*
To block anything mentioning ads regardless of it's type or location:
*ads*
Note: This rule is very broad and will also match anything ending, beginning or containing the keyword, such as knee_pads.
A further suggestion to reduce false positives.
I personally find that using the original example rule *google.* is too broad. When I wish to block content from a domain, I prefer to be a bit more specific. Using the directory indicator, a forward slash /, you can specify content to be blocked only if it's being loaded from with a directory (including root) of the website. This way, any files contain would normally match the rule will now be ignored. Only directories and their contents are affected.
For example, the following rule is a modified version of the original google block, but much more specific:
*.google.*/*
This rule states: Block only content that is located within a directory or domain containing the characters .google., but if it's a file containing .google. dont touch it. (Such an an image called: headers.google.jpg)
The first asterisk followed by a period is used to reference any hostname or sub-domain, such as www.google.com, or images.google.com. This sort of pattern is very common for the URLs and websites which advertisements are referencing, but not for files. Most embedded advertisements are loaded from sites such as www.example.com, or ads.example.com. Very rarely will you see an ad loaded from simply example.com (note the lack of a hostname or subdomain). However, filenames and directories hardly ever use this sort of pattern.
Removing or modifying a rule.
To remove a rule, open the Adblock configuration window, then simply right click the desired rule and choose Delete. (Now would be a good time to remove the sample *google.* rule we created in step 4)
To modify a rule, right click and choose Edit, then make the necessary changes.
Top Blocking elements using the context menu.
Using the Adblock Preferences window (as explained above) allows you to block elements based on a pre-configured list, i.e. if you know the specific pattern/URL you wish to block. However, if you want to block existing content on a website, it can be a bit more complicated to obtain the full (or partial) URL or pattern that will be used to block the element. Where do you start? Not everyone likes digging through raw HTML source code.
Luckily, Adblock addresses this issue. Included in the context (right click) menu is an option which allows us to easily and quickly block most elements we see on a page, as well as identify their source (URL).
Blocking images, frames and other "standard" embedded content.
We are going to block the primary google logo from the homepage (don't worry, it's only temporary!).
- 1: Go to the Google homepage and right click the image you wish to block, (in this case the google logo). Then select Adblock Image.... [Show]
- 2: This will open the Add Adblock Filter window. Don't feel overwhelmed, there are quite a few options presented. For now ignore everything and select Custom. This shows the full URL to the selected element (the logo in this case). [Show]
- 3: Simply click Add Filter and the image will be blocked from this moment on. (Or at least until we remove the rule.)
To remove the block/rule, open the Adblock Preferences window (left click the Adblock icon in the Toolbar or system tray), scroll to the bottom of the list and delete the last rule.
If the image you wish to block is being applied as a background, repeat the above steps, but select Adblock Frame instead of Adblock Image.
Most websites will have a single (or a relative few) directories that contain all the ad-related images and scripts. If there is rotating image banner, you can adjust the value shown in the Adblock Filter window to broaden the block by using the asterisk character. If for example the URL for an ad-based image is: http://images.ads.example.com/set1/freecar.jpg, you can change the value of the block to: *ads.example.com/*. This new rule will be much more inclusive. It will not only block the image you specified, but everything from the entire ads sub-domain.
Blocking backgrounds.
Adblocking a background is a bit different. The older versions of Adblock included a nice "Adblock Background" option available in the context menu, the new version does not.
The best and most accurate method for blocking a background image is to manually obtain it's URL and add it as a rule.
- 1: Right click the area over the background image. Firefox will display a View Background Image option, select it. [Show]
- 2: This will display the selected background image in the browser along with it's full URL in the address bar. Select and copy the URL. Now open the Adblock Preferences window, insert a new rule (insert key), paste the URL and hit enter. [Show]
Note: You can try blocking the checkered-gray background that spans horizontally across the top of this page. (Here is the image's full URL.)
Blocking Flash and other "non-standard" elements.
Blocking Flash and other "plug-in based" elements is very easy to do with Adblock Plus.
- 1: Whenever a Flash or Java applet is embedded in a page, Adblock adds a handy little Block tab in the top right hand corner of each element. Using the website in the example image, the tab will block the "Videos being watched right now" flash object. [Show]
- 2: Simply click the Block tab. Adblock will ten open a new Adblock Filter Rule window with the pattern field populated with the flash movie's URL. Make any necessary adjustments (such as selecting custom or adding a wildcard) and click Add Filter. [Show]
Top Techie PC's Adblock Blacklist
This is the blacklist produced by Techie PC that has been compiled over the course of a number of months.
A great deal of time has been spent visiting many of the most popular websites, such as youtube, yahoo, download.com, various news sites, game sites, social networking sites such as myspace and facebook etc. to gather a list of the major advertising sites and common ad-related phrases.
This list has been tailored to block approximately 95% or so of all standard embedded banners, iframes, flash videos and image advertisements. Every precaution has been taken when constructing this list to help reduce the chance of false positives. If you do find any false positives please feel free to contact me so I can correct them.
This list is updated periodically, depending on new ad-related domains and services that are developed, as well as occasional modifications to the current list to reduce false positives. It is recommended you check this page monthly for updates.
File last modified: August 04th 2009 - 10:01:00am