Update (2007-01-31): Included a fourth (Windows 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. Solutions 1-3 require Firefox—I’ve only tested with Firefox 2.0. Solution 4 should work with any browser on a Windows system.
Note: these solutions are targeted at Google and Yahoo ad services, to remove other ads you can use Adblock Plus along with one of the many filter sets available. Solutions 1, 2 and 4 only remove the ads, solution 3 also replaces them with boxes where the ads would have appeared.
1. AdBlock Plus extension
Install Adblock Plus and add the following two filters:
http://ypn-js.overture.com/*
and
http://pagead2.googlesyndication.com/*
If you’re already running AdBlock Plus, you can subscribe to my Google and Yahoo ad remover filter set, I’ll be adding to it soon.
2. CSS solution—no additional addons required
Edit userContent.css (use ChromEdit Plus or read Editing Configuration Files if you need help) and 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 Firefox.
3. Replacing Ads with Greasemonkey
Install Greasemonkey and then my Replace Google/Yahoo Ads script.
Before and after screenshot:
![[2 screenshots]](/wp-content/images/2006-replace-ads.gif)
4. Windows hosts
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. It’ll be found in one of these locations, depending on your version of Windows:
Windows XP = C:\WINDOWS\SYSTEM32\DRIVERS\ETC
Windows 2K/NT = C:\WINNT\SYSTEM32\DRIVERS\ETC
Windows 98/ME = C:\WINDOWS
Open it with a plain-text editor, e.g. Notepad, and add the following two lines:
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 methods 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 easy-to-use 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 CustomizeGoogle extension removes ads from Google search results, GMail, and more.