Version 6 (modified by speck, 12 years ago) (diff)


Keyword expansion

GlimmerBlocker supports 2 forms of keyword expansion:

  1. Simple macro-based expansion just like Firefox.
  2. Javascript based expansion.

Macro based expansion

'%s' is replaced by the URI-encoded search term, and '%S' (capital-S) is replaced by the non-encoded search term.


The template for the 'trailer' keyword is:

When user enters "trailer right one", the template is expanded to:

which performs a "I'm Feeling Lucky" search on Google which automatically redirects you to the Apple site. try it

Javascript based expansion

The javascript runtime is very much like that for the Javascript based transformations.

The differences are:

  1. None of the request related variables are defined: gb.contentType, gb.referer, gb.method,
  2. The gb.url and t variables are initialized to null.
  3. The search terms are stored in the gb.term global. An URI encoded form is stored in gb.encodedTerm
  4. The keyword is stored in gb.keyword. This is useful when the rule uses regexp to match multiple keywords.

Your script should either:

  1. Set the gb.url variable. GlimmerBlocker uses the url for a redirect response to Safari.
  2. Or set global variable t. GlimmerBlocker sends its content as html to Safari.

If neither variables are set, GlimmerBlocker proceeds to use the other rules which matches the keyword. The gb.url variable takes precedence over t.

  1. The object reference
  2. The request/response flow.
  3. Proxies overview.


The 'stock' keyword expansion have been implemented using Javascript. The code is:

gb.url = "" +
         "?Symbol=" + gb.urlEncode(gb.term.toUpperCase());

Regexp example

Keyword: java regexp "gg?" using Javascript expansion:

if (gb.keyword == "gg") {
  gb.url = "" + gb.encodedTerm + "&btnI=1";
} else {
  gb.url = "" + gb.encodedTerm;

The regexp matches either "g" or "gg". The javascript redirects to a "I'm Feeling Lucky" search when the keyword is "gg" and to a normal Google search when the keyword is "g".