How I built those firefox plugins to google search a site

Ok, so Mathias just asked how I managed to get the firefox search plugins to just search one site. I started to write a comment explaining it, but got a little long, so here’s Paul’s quick n dirty ghetto way of getting a firefox plugin to search just one site…

So basically, I got started by looking at the mycroft quickstart guide to building your first search plugin. That helped me to understand the basics of what I wanted to do, but really all I needed was a google search restricted to one site, just like typing site:livedocs.macromedia.com/flex/2 [myterm] into google.

The firefox search plugin format is pretty simple. Basically, you tell it what url to use, and then you can append querystring values on to the end of it using the following syntax:

<input name="parameterName" value="parameterValue/>

Then for the user input, you simple use the value ‘user’ instead of writing value=’blah’. So, if you take a look at the google search plugin source (should be found somewhere like ‘C:Program FilesMozilla Firefoxsearchpluginsgoogle.src’) you will see a node that looks like this:

<input name="q" user>

So, what I actually wanted to do is append ‘site:livedocs.macromedia.com/flex/2′ to my ‘q’ querystring value that the user enters. After a bit of digging, I found that you can repeat input nodes of the same ‘name’ and firefox simply joins these values together. so, in order to search just in the livedocs site, my input nodes looked like this:

<input name="q" value="site:livedocs.macromedia.com/flex/2 "/>
<input name="q" user>

You should be able to find my flex plugin source files in a location similar to this:

C:Documents and Settings[USERNAME]Application DataMozillaFirefoxProfilesytb1w5n7.defaultsearchplugins

. If you can’t be arsed to go digging, you can download them here and here

This entry was posted in Agile Software Development, Flash & Actionscript. Bookmark the permalink. Both comments and trackbacks are currently closed.