Quick Search Bookmarklets

Update: I do all this with Ubiquity now.

  • Quick Search: A feature of Mozilla browsers that allows you to store a bookmark with a variable and a keyword, to allow custom searches by typing the keyword and a search term into the location bar
  • Bookmarklets: Bookmarks that, instead of a normal URL, contain small javascript programs

What could be better than these? Combine them together!

In November 2005, I was trying to get rid of the Googlebar extension, since I didn’t use most of its features, and the parts that I actually used could be better met by more specialized, less Google-oriented extensions. For instance, the SearchBox Sync and SearchWP extensions have the same functionality as Googlebar’s terms toolbar, but use Firefox’s native search box and sync with any search engine; not just Google. Google’s translation service could be better met by a dedicated translation extension, like translator, or Translate, the Google cache feature could be replaced by a dedicated cache-viewing extension like any of these: 1 2 3 4 5 6 7 8

But what to do about Google’s site: search? (It lets you search for a term within the domain you are currently viewing.) I couldn’t find an extension to replace this functionality, but it’s a feature that I use regularly, so I couldn’t get rid of the Googlebar quite yet. There’s no way to do this with a Mycroft plugin, as far as I know, since it needs to know the site you’re currently on, in addition to the search term. Likewise, it couldn’t be done with a Quick Search, since the URL it generates only varies by search term; not the URL you are currently visiting. It could be done with a bookmarklet, but the search term would have to be entered into a prompt: popup, highlighted on the page before clicking the bookmarklet, or the like.

So why not use the Quick Search functionality for the search term (%s), the bookmarklet to determine what site you’re on (location.hostname), and the keyword for the interface? So I did. After some work (and several revisions), I use this:

If you drag it to your Bookmarks Toolbar and give it a keyword:

Screenshot of bookmarklet properties

You can then search for a term anywhere within the domain you are currently viewing by doing one of the following things:

  • Enter “site searchterm” into the Location bar
  • Highlight a search term on the page and click the “Site:” button in the Bookmarks Toolbar
  • Highlight a search term on the page and type “site” in the Location bar
  • Click “Site:” in the Bookmarks Toolbar and then type your search term in the prompt() window that pops up
  • Enter “site” in the Location bar and then type your search term in the prompt() window

So many possibilities!

Also, when I first wrote it, I could highlight a word and then select Site: from the context menu using the SmartSearch extension, which allowed me to leave the bookmarklet in my Quick Searches folder and still access it with the mouse without cluttering up my Bookmarks Toolbar. I rarely used this, though, and it appears to have broken; I don’t know if one of my changes broke it or if a change to SmartSearch broke it.

Other search keywords I use:

  • wp: Goes to the shortcut that I typed on Wikipedia. So if I type “wp wotta” it capitalizes it and goes to WP:WOTTA
  • wayback: Goes to the Wayback Machine listing for the page I am viewing (this isn’t actually a Quick Search, since it doesn’t involve any search terms, but I access it by typing “wayback” into the location bar, so I’m using a keyword and bookmarklet at the same time)
  • latest: Goes to the most recent archived copy on the Wayback Machine, like above

Don’t trust Google calculator

The term “kilobyte” means 1,024 bytes.



Most people reading this are experienced with computers and know that, in many computing contexts, kilobyte means 1,024 bytes. Descriptions of file sizes, memory, and so on. However, in some situations (and in the minds of most non-technical people; I’ve asked), kilobyte means 1,000 bytes. More importantly, units like kilobit usually mean 1,000 bits rather than 1,024. (Especially in the unit kilobits per second, or kbps, which always means 1,000 bits per second.) Google gets this wrong, and just uses 1,024 for everything. Wrong wrong wrong.

So any time you’re using Google to do computer-related calculations, be very sure you’re getting the result you want. I was first miffed by this when (at work) I stupidly trusted Google’s result about the bit rate requirements for streaming audio, for instance.

At the very least, they should provide a short explanation and disclaimer for calculations involving computer units, to explain the discrepancy to people who don’t know about it, especially given that confusion about the issue has resulted in litigation. Google calculator doesn’t seem like a huge target for lawyers, but they care enough to provide a little warning and disclaimer when you do a currency conversion:

Rates provided for information only – see disclaimer. More about currency conversion.

Even better, they could just do it right. Unambiguous units have been around since 1999, and have been adopted by standards organizations and open-source software.

Ironically, Google is aware of these units, but still uses 1,024 for both. For shame.

Update January 2008

I’ve actually talked to one of the employees who worked on Google Calculator.  He had already largely convinced the other maintainers that they should fix this, but left the company before he had a chance to implement it.

I’ve since discovered that GNU Units implements a lot of the same functionality, but:

  • You can use it offline, without webpage-loading delay.
  • It handles a lot more units and prefixes.
  • You can create your own units in a ~/.units.dat file.
  • It uses the standard definitions for “kilobyte”, “kB”, and “KiB”.
  • It runs on Unixes, Apples and Windows.


> units -1v "3 kilometers + 500 feet" yards
	3 kilometers + 500 feet = 3447.5066 yards

> units -1v "16 bit * 44.1 kHz * 2" kbps # Compact disc bit rate - Google gets this wrong.
	16 bit * 44.1 kHz * 2 = 1411.2 kbps

> units -1v "5 million pounds" megakilogram
	5 million pounds = 2.2679619 megakilogram

> units -1v "one hundred V / 5 ohms" A
	one hundred V / 5 ohms = 20 A

> units -1v "1/(2*pi*sqrt(10*microF*100 mH))" Hz # resonance frequency of an LC circuit
	1/(2*pi*sqrt(10*microF*100 mH)) = 159.15494 Hz

> units -1v "sqrt(mu0/epsilon0)" ohm # impedance of free space
	sqrt(mu0/epsilon0) = 376.73031 ohm

> units -1v "sqrt(4 k stdtemp 1 kohm (20 kHz - 20 Hz))" nanovolt # thermal noise of a resistor
	sqrt(4 k stdtemp 1 kohm (20 kHz - 20 Hz)) = 548.99727 nanovolt

> units -1v "furlong per fortnight" cm/minute
	furlong per fortnight = 0.99785714 cm/minute

> units -1v attoparsec/microfortnight inch/sec
	attoparsec/microfortnight = 1.0043268 inch/sec

Unfortunately, it cannot calculate the answer to life the universe and everything, but you should probably have that memorized, anyway.  You know, just in case…