Update August 3rd, 2010: This article is nearly three years old. These days I would
recommend GlimmerBlocker. It works great for
blocking ads, requires no browser plugins/extensions/whatever, is system-wide, and doesn't
seem to have any of the issues I've had with proxy solutions in the past.

Recently I've been getting assaulted by these annoying Vibrant popup
advertisements. They sort of look like hyperlinks, but with a double underscore, and if
you accidentally mouse over them, a new little window pops up blocking the document you're
reading with an annoying advertisement. When you load a page, Vibrant scans the
document your browsing and searches for keywords matching a database of sponsors. So if
you're reading a web page about computer gaming, it'll find the word game and turn
it into a advertising opportunity for the Microsoft X-Box 360.

Generally, I don't care that much about ads. I'm usually able to tune out most ads on a
page while browsing. But Vibrant provides a new definition of obnoxious, a
throwback to the whack-a-mole era of popups. It's another step in the old arms race
between advertisers and the rest of us--while we just want to read a web page for the
content, they're continually trying to make a buck by blitzing us with advertisements, and
are always a little too crafty at finding loopholes in our browsers to do it.

Now at this point you might ask, "Gee Steve, why are you affected by ads at all, surely
you're using Firefox and Adblock Plus, right?" The truth is I don't, I use Safari. While
I agree that Firefox has superior features (notably, a wealth of addons that block ads, or
aid with web app development), I simply like Safari better. It's faster, and I think it
looks nicer (certainly versus Firefox on the Mac) and is generally more pleasant for
day-to-day web browsing. And a lot of pople don't know it, but Safari has some
development tools of its own, you can enable the Debug
menu for debugging JavaScript, observing page behavior/correctness, and tuning
performance.

Until my recent Leopard upgrade, I'd been using Saft ($12), which in addition to some
basic ad blocking capabilities offered a number of bonus features, such as warnings before
closing a window with multiple tabs, restoring all windows from a previous browser
session, etc. When Leopard came out there was a lot of confusion regarding Mac OS's
InputManagers (I think it's pretty well-understood now),
and Saft wasn't quite ready out the gate. I realized fairly quickly however that the new
Safari had most if not all of these features I liked built-in. (Update: I see now that
Saft has been updated and appears to work fine, however I noticed it didn't appear to
block Vibrant ads out of the box. Hah, oh well).

While looking around I found what seemed like a compelling, cross-browser solution: Privoxy, a junk-busting proxy you run on your computer
(or centralized on your network if you want) that cleans up your pages. For Mac users, it
offers an easy solution: download, install, and update your proxy settings and you're
ready to go. However I found it wasn't quite that easy, after a bit of troubleshooting I
found I had to edit /Library/StartupItems/Privoxy/Privoxy and change the
daemonuser field to match a valid user on the system (in my case,
stevek). And then, I found the proxy bypass field in the Mac OS System
Preferences didn't quite behave as well as I wanted, it was still using the proxy for
machines on my company's intranet. I ended up learning how to write a Proxy Auto Config
(PAC) file to give me exactly what I wanted. It's kind of neat, you can read up on PAC
files starting at this Wikipedia
page, or check out the proxy.pac I came up with.

Here's an example before and after of an page with ads. Compare this
to what you see.

Unfortunately I started getting strange application crashes, an annoying popup every hour
stating The Application PubSubAgent quit unexpectedly. Some forums suggested it
was an Apple bug and proxy-related. And then periodically even Safari would crash on me.
And then I remembered, I hate proxies--especially corporate transparent proxies. I'd say
this approach to ad blocking is a great idea in theory but experience has told me that
proxies just suck--give me clean, unobstructed access to my web pages.

Finally just today I stumbled on what looks like a promising project: Safari AdBlock. Its tag line is
"Couldn't be more simple", and so far, I'd have to agree. There's virtually zero
documentation, and no way to customize it, just the claim that "it just works out of the
box". I'd like to know more about how it works, so I browsed through the source
a little, and noted the special thanks to AdBlock
Plus and EasyList, so it looks it this
leverages these existing, excellent products. Good stuff. I revisited various pages to
check for ads (notably the
one that launched this recent crusade), and it's clear Safari AdBlock is silently
working. It's free, it looks like it's doing a good job, and it's very small and
lightweight--all good things.

Goodbye, obnoxious Vibrant ads. Can't wait to (not) see what you come up with
next.

I'll take ya one further step. For the purpose of this article, assume
10.11.12.13 is the address on the LAN of the macintosh. If you do it ONLY
for the machine you are on, you can use dynamic IP/DHCP but must use
127.0.0.1. Me, I do it for the entire LAN including the people who borrow
my wireless so I have my machine in a static location on the LAN.

1. Get named running on your macintosh. Thats the Nameserver. Get it
running as an authoritative nameserver same as you would if you were
setting up to host a webpage - I bet you already know how to do this cause
you mention elsewhere you are hosting your own email server on your own
domain ... to make life easier for others, at the very bottom of the
named.conf, include:
# FAKE AD-BLOCKING DOMAINS FOLLOW

2. Make records for your own machine for popular advertizing domains. This
is made easier with a script I wrote for this purpose after doing the first
few by hand. You can put this in /var/named alongside all the files:

The script is ANYTHING BUT FAILSAFE. If you have any sort of problem, check
console! Even blocking the same thing twice can trigger major problems with
named! I really only added that script to eliminate the hassle of typing
the same thing over and over and over again without taking the more usual
step of organizing the repetitiveness, because I'd like to have the option
of individually redirecting those domains creatively at a later date.

3. Get your Apache server ready for some fun!
OK, if you are actually using Apache for anything at this point, maybe you
want to dedicate a separate machine to this task? Or do a whole lot more
work with virtual hosts (including adding to my script to make it easier!)
But here's the gist of it all... add the following additional lines to the
section specifying the error documents:

This is beautiful (but not yet done, when done I intend to handle various
sizes as well as requests for common locations of javascript!) because it
means blatant requests for images are treated to an image, but requests for
anything else are assumed to be the all too common IFRAME embeds, and are
treated as HTML. Actual images get thru by using a capitalization trick
(avoiding endless redirect), the HTML served shows an image and a "No
ads for me!" type slogan.

On Fri Jan 11th 2008, 2:20pm, Steve Kehlet posted:

That's a great hack, thanks for the post Zaphraud.

On Mon Jan 4th 2010, 9:14am, Visitor posted:

You're an idiot... this is useless! It's 2009 for god sake!!! Uodate this
crap!!!

On Mon Jan 4th 2010, 9:16am, Visitor posted:

Could you have made this any more complicated? Hosts file mod is the way to
go, but no one has a comprehensive, easy to use guide for doing this on a
Mac. Hint!

On Mon Jan 4th 2010, 9:16am, Visitor posted:

Could you have made this any more complicated? Hosts file mod is the way to
go, but no one has a comprehensive, easy to use guide for doing this on a
Mac. Hint!

On Thu Jul 15th 2010, 7:37pm, VisitorUnhappy posted:

Steve, your article is basically full load of crap info. It would be nice
if you come to the point straightforwardly. This will save your reader some
time. Nobody want to read crap when solution is not offered in first two
lines of the paragraphs. Sorry for pique comment.

On Thu Jul 15th 2010, 11:08pm, Steve Kehlet posted:

Lol, what a great comment. Thanks for stopping by.

On Mon Aug 2nd 2010, 6:01pm, Eric posted:

I have to admit, Safari adblock has completely failed to do the job. I can
see Vibrant ads, and yes, I set my Safari to open in 32 bit mode.

On Tue Aug 3rd 2010, 12:38am, Steve Kehlet posted:

Weird. I should put a note at the top of this (obsolete) article to check
out Glimmerblocker. It works great, is cross-browser, and doesn't seem to
have any of the issues I've had with proxy solutions in the past.

On Wed Feb 15th 2012, 7:05pm, n1tr0g3n.com posted:

Here's a link, to disable these annoying ads just click on disabe with each
browser you use & if you clean your cookies or reinstall the browser or
OS you'll have to do it again. So just keep the link as a bookmark on your
browser or email. The damn Vibrant ad's are sooooo annoying I'm glad I can
finally avoid them now!