How to create a Firefox Search Plugin – OpenWorldCat

Taking a break from talk of bigger ideas, here’s a simple thing you can do to add value and make it easier to search your offerings. I’m one of those people that prefer not to install a whole toolbar though I may be prone to install a search plugin or extension. I try to keep my UI free of too much clutter. I created one for my library back in May since it was so easy and since there has been a recent interest in it I thought I’d share how easy it is. If you can code a form in html or actually read form code off a page then you can create a plugin. For this example I will create one for OpenWorldCat through Google since I currently find it a pain in the ass to search it otherwise.

First lets take a look at the code you can use in a webpage to search OpenWorldCat via Google:

<form action="" name="f">
<input maxlength="256" size="40" name="q" value="" />
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="oe" value="UTF-8" />
<input type="hidden" name="hl" value="en\" />
<input type="hidden" name="domains" value="">
<input type="hidden" name="sitesearch" value="" />
<input type="submit" value="Search Google" name="btnG" />

I took most of this code I believe from Google and the OCLC demo. Now that we know what form inputs are used, we can start to create the source file for Firefox. In this example I am going to name it worldcat.src though you can name it as you wish. Here’s what the final source will look like. I’ll talk about the various parts afterwards:

# Mozilla+ search plugin for Google Open Worldcat Keyword Search (
# Author: Ryan Eby
# Created: 28 December 2005
# Last Modified: 28 December 2005
# Country: US
# Language: en
# Category: 5 (Reference)
# Known issues: None.

name="OpenWorldCat - Google"
description="Search OpenWorldCat via Google"
method="GET" >

<input name="q" user>

<input name="ie" value="UTF-8" />
<input name="oe" value="UTF-8" />
<input name="hl" value="en" />
<input name="domains" value="">
<input name="sitesearch" value="" />

# Dummy section added to prevent spurious links parsing



Header Information

The first thing you will notice is the header information. This should include information on who wrote it, when it was created, when it was last modified, etc. This information is actually more for developer use than anything and helps others if they decide to modify it.

Search Information

This is where we include information on how we are going to search. First we specify the version of Netscape that the plugin is tested against. The documentation suggests 7.1. We then choose a name and description. We then set-up the actual form. As you can see I used the same action that the original form has. I used the same thing for searchForm as that will still take you to a Google search box at least. The rest of the inputs are the same as our form except that I removed the “type=hidden”. You’ll also note that the name=q input has user added to the end. This is what tells Mozilla that this is the input that the user will be entering.


You can do some advanced things with the result set that comes back. In this case I just want the normal results page and I found the above works well. I’m not certain where I found it anymore. You can find out more about the interpret options on the mycroft documentation site for it.


As you can probably tell this is the area where you specify where your src file and your graphic are located. It also specifies how often it should check for an update. Depending on how often you are tweaking the code you may wish to change this value.

How to Offer It

Now that you have a src file you probably want to offer it for installation. You may also want to provide an image. It should be named the same as the source file, be 16×16 pixels and be either jpg, gif or png. You will want to upload both of these files to a directory on a webserver. You then include the following code in an html page, replacing the URLs with the correct paths to your files.

function errorMsg()
alert("Netscape 6 or Mozilla is needed to install a sherlock plugin");
function addEngine(name,ext,cat,type)

//cat=prompt('In what category should this engine be installed?','Web')
"http://localhost.localdomain/plugins directory/"+name+".src",
"http://localhost.localdomain/plugins directory/"+name+"."+ext, name, cat );


The code above will allow you to link to as many plugins as you want. You do so by adding the following to your html:

<a href="javascript:addEngine('worldcat','png','Reference',0)">OpenWorldCat Plugin</a>

As you can probably tell the information you pass in the addEngine area is the name you used for your files, the extension you used on your image and the category of the plugin. In this case I chose Reference. More information on installation can be found at the mycroft site.

In the end you should end up with something like this. Of course the page I created is bare. Give it a whirl and comment if you have problems.

  1. typeof window.sidebar == "object") && (typeof
    window.sidebar.addSearchEngine == "function" []

4 Responses to “How to create a Firefox Search Plugin – OpenWorldCat”