Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use GlimmerBlocker keywords in Google Quick Search Box Apps
GlimmerBlocker is a fantastic proxy-based ad remover and content filter for Mac. The biggest benefit is that since it does not use InputManagers, it works perfectly with Snow Leopard. One of the best features of GimmerBlocker is keyword expansion (akin to Keywurl). Type hulu house in the address bar, and GimmerBlocker directs Safari to Hulu, executing a search for House.

However, for me, quick web searches like this usually start from the Google Quick Search Box. This hint allows all GlimmerBlocker keyword expansions to be initiated from the Google Quick Search Box, by writing two rules in GlimmerBlocker.

Here is the GB XML for the two rules:
<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
 <rule priority="2" type="request" path="/" path-type="is">
     <comments><![CDATA[Google Search bad requests.]]></comments>
     <request language="js" version="1"><![CDATA[var h =
gb.request.urlHost;

if (h.match(/([%]+)/) ) {
gb.response.sendRedirect("http://www.google.com/search?q=" + h);
}]]></request>
 </rule>
 <rule priority="2" type="request" host="www.google.com" host-type="is"
query="&amp;client=qsb-mac" query-type="contains">
     <comments><![CDATA[Forward QSB Quick Search keywords]]></comments>
     <request language="js" version="1"><![CDATA[var m =
gb.request.urlQuery.match(/&q=([^&]+)&client=qsb-mac/);

if (m) {
var newURL ="http://" + m[1];
gb.response.sendRedirect(newURL);
}

else {
gb.response.sendText("GlimmerBlocker recognized a request from Google QSB,
but search failed to match URL: '" +
gb.htmlEncode(gb.request.urlQuery) + "'");
}]]></request>
 </rule>
</glimmerblocker-rules>
Copy the above code, select a filter, and paste it into the "Rules in [this filter]" panel of the GlimmerBlocker preference pane.

Essentially, the first rule looks for the client=qsb-mac tag in a Google search, since that flag is appended only for Google Quick Search Box queries. It then strips everything but the actual query and resubmits to Safari:

Original URL: www.google.com/search?client=qsb=mac....q=key%20whatever%20else
Modified URL: http://key%20whatever%20else/

Usually, this would return a "Page not found" error, since that is obviously a poorly-formatted URL. Except that in this case, GlimmerBlocker recognizes this as matching the keyword key, and then follows whatever rule is associated with key.

The second rule is a catchall for poorly-formatted, multi-word addresses submitted to the Safari address bar. It (like Firefox does natively) submits these bad queries to Google.

Original URL: http://NOkey%20whatever%20else
Modified URL: http://google.com/search?q=NOkey%20whatever%20else

[robg adds: I haven't tested this one.]
    •    
  • Currently 2.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (7 votes cast)
 
[5,479 views]  

Use GlimmerBlocker keywords in Google Quick Search Box | 4 comments | Create New Account
Click here to return to the 'Use GlimmerBlocker keywords in Google Quick Search Box' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use GlimmerBlocker keywords in Google Quick Search Box
Authored by: Andrew J Freyer on Oct 05, '09 09:45:35AM
Something I forgot in the hint:

Copy the XML to the clipboard.

In order to paste this rule directly into GlimmerBlocker, select or create a new filter, then click the 'Rules in "ThisNewFilter" ' Box, which will then become highlighted.

Then simply paste - Command + V, and both rules will be imported.


Alternatively, you can subscribe to the filter here: http://idisk.mac.com/andrew.freyer/Public/keyword-expansion-extend.xml


[ Reply to This | # ]
Use GlimmerBlocker keywords in Google Quick Search Box
Authored by: unfletch on Oct 05, '09 02:05:42PM
Awesome, thanks! I don't use the Google Search Box, but I made some minor modifications to enable keyword searching from Safari's search box instead:
<?xml version="1.0" encoding="UTF-8"?>
<glimmerblocker-rules>
    <rule priority="2" type="request" host="www.google.com" host-type="is" query="client=safari" query-type="contains">
        <comments><![CDATA[Forward QSB Quick Search keywords]]></comments>
        <request language="js" version="1"><![CDATA[var m = gb.request.urlQuery.match(/&q=([^&]+)/);

if( m ) {
  var newURL ="http://" + m[1].replace( /\+/, "%20" );
  gb.response.sendRedirect( newURL );
} else {
  gb.response.sendText( "GlimmerBlocker recognized a request from Google but search failed to match URL: '" +
  gb.htmlEncode( gb.request.urlQuery ) );
}]]></request>
    </rule>
</glimmerblocker-rules>


[ Reply to This | # ]
Use GlimmerBlocker keywords in Google Quick Search Box
Authored by: Andrew J Freyer on Oct 05, '09 05:21:50PM

I gotta ask though...

Why do you want the keywords in the Search box? Its just an inch from the address bar...

I did this through QSB so that I could launch a query to any site from the keyboard, without launching Safari. Once I'm already in Safari, I'm not sure I see why keyword searching from the Safari search box is any different from searching within the address bar?



[ Reply to This | # ]
Use GlimmerBlocker keywords in Google Quick Search Box
Authored by: unfletch on Oct 05, '09 11:02:51PM

It took me forever to break the habit of typing searches in the location bar after switching from Firefox. I don't think I could go through that again in order to switch back. :)



[ Reply to This | # ]