Saturday, 5 January 2008

Online advertising and how to get rid of it

Online advertising wouldn't be a problem if the adverts were like the google ads that some sites host but in the main they are not. Usually they are large and obtrusive. I cannot stand seeing huge, bright, flashing, moving advertisements in the middle of web pages I am trying to read. They distract from the content so much that I find it difficult to read it.

To the right are two images of the same webpage. The first is with advertising and the second has had it removed by the squid proxy method I describe below. The purple advert is a very large animated advert. This news site has also been known to use pop-up video advertisements, something I find highly offensive.

I am not the type of person who clicks on advertisements. Never have, never will. Because of this I feel no guilt whatsoever using methods to reduce the amount of advertising I see. The first method I use is open to everyone.

Use Firefox and install two extensions: Adblock and Flashblock. Adblock allows you to right click on any element in a page and add it to a blacklist. Once on the blacklist the element will never be displayed again. Flashblock replaces any flash element on a page with a clickable button. If you want to view the flash, click on the button.

The second method I use is a little more complicated. You probably need to be a bit technically proficient to use this method.

I use a Linux distribution called IPCop as a firewall. A web proxy program called Squid (Squid website Wikipedia page) is included with IPCop. A web proxy caches web pages so that pages load faster if you request a page again. The proxy sits between your browser and the internet and fields any request for web pages. Each request is checked to see if it exists in the cache and, if so, it is retrieved and sent to you without the need to actually fetch the page from the internet.

Squid allows you to allow or block access to almost anything available through the web. Using third party filter programs or Access Control Lists (ACLs) you can set it up to block known advertising sites (or any other content you do not want).

You don't have to run IPCop to use Squid. In fact, you don't have to run Linux either as Squid will happily run on Windows as well. Download it, install it, configure it, point your browser at it and there you are - your own proxy which will allow you to control what your browser sees.

Once you have installed and configured Squid (which I am not detailing) you can set it up to block sites you don't want, including advertising. You can either download and install one of a number of filter programs that work with Squid (Dansguardian SquidGuard for example) or you can use the method below.

Why not use one of the filters? Personally, I find them too restrictive and think they complicate things too much. However, they do allow a fine grained degree of control over what gets stopped and who can view what. I just want to stop advertising so I use this method.

Create a text file called badsites.txt. In this you can enter the domains of the sites you wish to block. To get it started, go to the SquidGuard site and find the links to the various blacklists. Download one or more of the blacklists, extract them somewhere, find the files that pertain to advertising domains/urls, and combine them into one file.

Edit the file squid.conf. Find the section that deals with ACLs. Just below the area that defines the standard ACLs, add this line:

acl ads dstdomain "/path/to/the/text/file/badsites.txt"

Replace the "/path/..." with a legitimate path to the text file you created.

Find the area where you can add your own access rules and add this line

http_access deny ads

Restart squid and test it out.