Remove Google and Yahoo Ads
Update 2 (2011-01-08): Updated with instructions for Chrome users.
Update 1 (2007-01-31): Included a fourth (hosts) method for getting rid of ads.
More and more sites are displaying Google (AdSense) or Yahoo (YPN) ads. I thought I’d post up 4 simple ways you can get rid of these ads, and, if like me, you’d still like to know which sites use them but don’t really want to see the ads, there’s even a solution to replace them with boxes.
Note: these solutions are targeted at Google and Yahoo ad services, to remove other ads you can follow the steps in my ad-free browsing guide. Solutions 1, 2 and 4 only remove the ads, solution 3 also replaces them with boxes where the ads would have appeared.
Solution 1. AdBlock Plus extension
Install Adblock Plus for Firefox or Adblock Plus for Chrome and add the following two filters:
http://ypn-js.overture.com/*
and
http://pagead2.googlesyndication.com/*
Solution 2. CSS—no additional addons required
In Firefox, you can edit userContent.css (read Editing configuration if you need help). In Chrome, you’ll have to find ‘Custom.css’ (on Windows, this will be at appdata\Local\Google\Chrome\User Data\Default\User StyleSheets\Custom.css). In that file, add the following two rules:
/*
* Remove Google ads
*/
iframe[name='google_ads_frame'],
a[href^='http://pagead2.googlesyndication.com']
{ display: none ! important; }
/*
* Remove Yahoo ads
*/
iframe[src^='http://ypn-js.overture.com']
{ display: none ! important; }
Save and restart the browser (Chrome appears to apply the rules immediately as soon as you save the file).
Solution 3. Replacing Ads with Greasemonkey
In Firefox, install Greasemonkey (Chrome needs no extension) and then my Replace Google/Yahoo Ads script.
Before and after screenshot:
Solution 4. hosts file
This is based on Tech Support Alert’s in-depth guide to Removing Google Ads Using the Windows Hosts File. Read that if you’re unfamiliar with the Windows Hosts file.
Locate the hosts file. Open it with a plain-text editor, e.g. Notepad, and add the following three lines:
127.0.0.1 pagead.googlesyndication.com
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 ypn-js.overture.com
Any feedback appreciated.
Ads on Google and Yahoo websites
The solutions above will not block ads appearing on Google or Yahoo’s own websites, e.g. Gmail or Yahoo Mail, as most of those ads are fetched server-side and not through the HTML snippets most webmasters receive when signing up to AdSense/YPN. You will however find Firefox extensions and Greasemonkey scripts targeting those sites specifically. For example, the excellent OptimizeGoogle extension removes ads from Google search results, GMail, and more.