|< Day Day Up >|
Many advertisements can be blocked in Firefox by using an extension named Adblock. Adblock lets you create, import, and export filter lists to block content.
Installing Adblock is relatively easy: Start at http://adblock.mozdev.org/ and read about the Adblock project. On the navigation bar at the top of the page click Install (see Figure 5.4). This option takes you to the Adblock installation page.
Figure 5.4. The Mozilla Adblock home page (http://adblock.mozdev.org) is the Adblock home page. Note the navigation bar at the top.
When you're at the installation page, install the latest build. (Most likely the latest build is the only build available.)
Adblock is an easy extension to use. You configure Adblock by selecting Tools, Adblock in Firefox. This displays a second level of menu selections:
By default, Firefox is configured to block installation of software or extensions except those on the approved list. If this blocks your installation of Adblock, an error status bar appears below the Firefox toolbar (or the tab bar if you have a tab bar displayed). By default, the various Mozilla sites are preapproved.
Figure 5.5 shows the Adblock Preferences window. This window enables you to create new filters by typing them in the New Filter box and clicking Add.
Figure 5.5. In Adblock's Preferences window, you can set options and create new filters.
In addition to allowing you to create new filters, the Adblock Preferences window also lets you set Adblock options and display help (this actually comprises two links one to the Adblock home page and a second link to a page that describes regular expressions).
The Adblock options you can configure include
There is nothing to prevent you, or anyone else, from creating all the necessary filters. But, an old rule of computing says, "Don't reinvent the wheel!" This means that, if filters already exist that work well, then use these instead of writing your own. One site that has Adblock filters that are updated every few days is at http://www.geocities.com/pierceive/adblock/.
Importing, Exporting, and Removing Filters
Adblock allows you to import, export, and remove filters. This capability is the heart and soul of Adblock's functionality. Sites that serve advertisements change frequently, old sites disappear, and new sites pop up with startling regularity.
As well, sometimes it is best to just start with a clean slate. You can remove all existing filters if necessary.
Importing filters lets you load filters you have created and exported (see the next section, "Exporting Filters," for details on exporting filters). A Google search shows many sites that list available filters.
Don't ignore filter lists that originate from outside your country. A filter list from Germany can work just as well as one from the United States usually. The best advice here is to try it and see if you like it.
Importing is done from Adblock's Preferences window. Click Adblock Options, and select Import Filters from the menu displayed. This opens the Select a File window, which is the Windows Open File window, renamed. Select your text-based filter file. This file must have an extension of .txt; if it doesn't, enter a filename of *.* to see all files available in the target folder. After a file has been selected, a Confirm window asks you whether you want to overwrite the current list of filters or append to the end of the list.
The filter file format is a simple text file. However, Notepad will not effectively edit this file because the lack of carriage returns in the file causes Notepad difficulty. Instead of Notepad, edit this file with WordPad, and you should be set!
The first line (and only mandatory line) contains
Each subsequent line contains one filter per line. The filters can be URLs, with an allowed * as a wildcard character. Also allowed are GREP, such as regular expressions. In Adblock regular expressions begin and end with a forward slash (/).
Regular expressions are strings that contain a complex wildcard syntax to allow matching multiple strings. If you want to learn all about regular expressions, many sites on the Internet can help you. One that I can recommend is http://www.regular-expressions.info/reference.html. Anyone familiar with GREP utilities should understand regular expressions.
Adblock lets you export their filters. When exporting, Adblock prompts for a filename to save to. I recommend supplying both a filename and an extension of .txt which is not supplied by default. An exported filter set can be directly imported into Adblock as desired.
Exporting filters provides a great way to both back up and share your filters.
Adblock's Remove All Filters option enables you to clear all filter definitions, which is useful if you want to start from scratch. If you will be loading new filters, you don't need to remove the existing filters. Rather, simply click OK in the Confirm dialog box.
Adblock stores filters and Adblock option settings in prefs.js. There are a number of lines in this file for Adblock, as the following code shows:
user_pref("adblock.enabled", true); user_pref("adblock.fastcollapse", false); user_pref("adblock.frameobjects", true); user_pref("adblock.hide", false); user_pref("adblock.linkcheck", false); user_pref("adblock.pageblock", false); user_pref("adblock.patterns", "ads.com adserv.com advertise.com");
Settings are saved for a number of Adblock options, including the following. (Please note that not all versions of Adblock support all the options listed here.)
You could put Adblock settings in user.js. However, doing so has no effect. Adblock checks for settings only in prefs.js, and not in user.js.
|< Day Day Up >|