GlimmerBlocker Logo

GlimmerBlocker

HTTP based ad blocker for Mac OS X

No hacks, no instability
Upgrade Safari whenever you like, no need to wait for an upgraded hack

GlimmerBlocker is no longer maintained and should no longer be used as web sites have migrated from using plain http to using https (i.e. encrypted) which prohibits modification by a proxy unless you resort to install custom SSL certiticates on the client.

You should use a browser extension instead.

It was made as a hobby project during 2007-2008 by Peter Speck. It features both a custom http server and http client and a Mac OS X control panel.

GlimmerBlocker did not only block requests but also allowed for adding custom css and javascript to the pages. It also allowed for modification of the page html before the browser receives the html, which made some modifications much easier than DOM based modifications.

Assorted Tips & Tricks

Copy/paste and dragging rules

In the rules table you can drag the rules to/from the Desktop or an email, or ....

When you drag a rule to a text document (e.g. email), you will get an xml snippet:

<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
    <rule host="pub.clicksor.net" host-type="is" priority="2" type="block">
        <comments><![CDATA[pop-behind when clicking links]]></comments>
    </rule>
</glimmerblocker-rules>

When you receive such a snippet in the email, just copy the xml and paste it into the rule table in your own filter. (You cannot paste into a filter subscription).

How to generate a log file

When a site doesn't work due to GlimmerBlocker failing, it helps me a lot getting a log file with all the details.

  1. Open the GlimmerBlocker System Preferences Pane
  2. Select the "Developer" tab.
  3. Check all the checkboxes in "Server log" section.
  4. Try go to the site that fails, and do the thing that fails.
  5. Uncheck the checkboxes.
  6. Click "Show log" and send me the contents of the GlimmerBlocker.log file.

Rule that hacks the referer

Some 'free' image hosts won't display images unless the request has a 'proper' referer header. You can fix this with a request rule like this:

<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
    <rule priority="2" type="request"
          host="www.badimageserver.dk" host-type="is" path="/img/" path-type="starts-with">
        <comments><![CDATA[set referer]]></comments>
        <request language="js" version="1"><![CDATA[var r = gb.request.referer;
if (!r || !r.match(/badimageserver\.dk/)) {
    gb.request.referer = "www.badimageserver.dk";
}]]></request>
    </rule>
</glimmerblocker-rules>

Keyword rule that searches Google and Bing

This keyword rule returns an html document which is a frameset. The two frames contains a link to the two sites and includes the search query.

<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
   <rule priority="2" type="keyword" keyword="z" keyword-type="is">
       <keyword language="js" version="1" keyword-uses-js="1"><![CDATA[t = "<frameset rows='50%,50%'>" +
    "<frame src='http://google.com/search?q=" + gb.encodedTerm + "'>" +
    "<frame src='http://bing.com/search?q=" + gb.encodedTerm + "'>" +
    "</frameset>";]]></keyword>
   </rule>
</glimmerblocker-rules>

Catching keywords in the 'Google search' field

The URL input field has a problem with special characters such as quotes, but the Google search field doesn't have that problem. So a nice workaround is to create filters which intercepts some Google searches and redirects them to other sites.

Example: catch searches which starts with "hulu" and redirect them to searches on the hulu.com site. E.g. searching for "hulu tonight show" should search for "tonight show" on the hulu.com website. This can be implemented by creating a request rule which matches the host "www.google.com", the path "/search" and which has a query that contains "&q=hulu+". The rule then creates a hulu.com URL and sends it back to Safari without contacting Google. The rule is:

<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
   <rule priority="2" type="request"
          host="www.google.com" host-type="is"
          path="/search" path-type="is"
          query="&amp;q=hulu+" query-type="contains">
       <request language="js" version="1"><![CDATA[
var m = gb.request.urlQuery.match(/&q=hulu\+([^&]+)/);
if (m) {
    gb.response.sendRedirect(
        "http://www.hulu.com/videos/search?query=" + m[1]);
} else {
    gb.response.sendText("GB hulu search failed to match URL: '" +
        gb.htmlEncode(gb.request.urlQuery) + "'");
}]]></request>
   </rule>
</glimmerblocker-rules>

You can select the search field by typing Cmd-Option-F.