YubNub for Safari using GlimmerBlocker
Just recently I found out about YubNub by watching Remi’s screencast, which was listed on Learnivore. However, none of the installation instructions listed for Safari seemed to work on my machine (Snow Leopard, Safari4).
A cool program that acts as a HTTP proxy for Safari is called GlimmerBlocker. Besides being a great adblocker, it supports keyword handling by passing the text entered in the Safari address bar through a list of filters. Some keywords that are common to Yubnub users are already defined, like for example ‘gim’ for google image search or ‘y’ for a Yahoo search.
It was an easy step to add a new filter that passes commands to Yubnub instead. This is by far the most elegant solution I found to have Yubnub integration into Safari that doesn’t hack Safari and works for any version of Safari.
The installation consists of installing GlimmerBlocker and defining one simple filter. Here are the steps to take:
- Download and install GlimmerBlocker
- Go to the GlimmerBlocker Preferences Pane (listed in the ‘Other’ section of your System Preferences
- Check ‘Activate GlimmerBlocker’ in the Setup tab
- Go to the Filters tab and create a new filter. Name the new filter ‘YubNub’
- Select the new filter by clicking on the name and enable it by checking the checkbox next to it
- In the bottom part of the pane, create a new rule (OR paste the rule XML described in the next paragraph!). Get it to look like the following screenshot:
The keyword used is ‘.*’ (dot star), meaning that this will handle any keyword that is detected. Since it will accept any keyword, the priority of the rule is the lowest to give precedence to rules with more specific keywords.
gb.url = "http://www.yubnub.org/parser/parse?command=" + gb.keyword + "+" + gb.encodedTerm;. It should now look like this:
- Save the rule.
- Try it out by entering some YubNub commands in the Safari address bar! Safari doesn’t have to be restarted for new rules to be applied, so you can tinker with it very easily. Check out the YubNub website for some example commands!
YubNub Rule XML
A really cool feature of GlimmerBlocker is that rules can be shared. By pasting the following XML into the rules table of the YubNub filter, you can skip all rule configuration steps described above!
<?xml version="1.0" encoding="UTF-8"?> <glimmerblocker-rules> <rule priority="1" type="keyword" keyword=".*" keyword-type="regexp"> <comments><![CDATA[Send YubNub commands]]></comments> <keyword language="js" version="1" keyword-uses-js="1"><![CDATA[gb.url = "http://www.yubnub.org/parser/parse?command=" + gb.keyword + "+" + gb.encodedTerm;]]></keyword> </rule> </glimmerblocker-rules>