Saturday, August 8, 2009

Howto make a search plugin in Firefox

I wanted to search for some lyrics on a site. Evry time I had to type the same keyword site:www.ssdad.com along with the search terms.
So I went ahead and modified a search engine already installed to get around this hassle.
What I did to create my own custom search engine in Firefox is as follows -
  1. I went to the directory home/.mozilla/firefox/asrfafae.default/searchplugins
  2. Copy pasted any search plugin already installed.
  3. Opened the xml file in a text editor.
  4. I modified it to my advantage (the bold ones) -

    <' SearchPlugin xmlns="http://www.mozilla.org/2006/browser/search/" xmlns:os="http://a9.com/-/spec/opensearch/1.1/" '>

    <' os:ShortName'>musicindiaonline.com<'/os:ShortName '>

    <'os:Description'>hindi Lyrics Search - MusicIndiaOnline.com<'/os:Description'>

    <'os:InputEncoding'>ISO-8859-1<'/os:InputEncoding'>

    <'os:Image width="16" height="16"'>data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAwBQTFRFAP8A////PZk9/4xpAAAA//8AzYU/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAW3InEQAAAGhJREFUKFM9jwESADEEA0k1/3/yJdQZ02GJEhEZv3WYrAVJKCTMYTo1gMV7L1HbC+dGq1WO8TdMoOS8HKDS2rSo2kPU8TS0wponsaaq9C7I/XZmZkK7qaz9Gpz0KPQVHc4ZY2dX+0nEBzwTAjxlQT/PAAAAAElFTkSuQmCC<'/os:Image'>

    <'UpdateInterval'>7<'/UpdateInterval'>

    <'UpdateUrl'><'/UpdateUrl'>

    <'IconUpdateUrl'><'/IconUpdateUrl'>

    <'SearchForm'>http://www.google.co.in<'/SearchForm'>

    <'os:Url type="text/html" method="GET" template="http://www.google.co.in/search?q={searchTerms}+site%3Ahttp%3A%2F%2Fwww.ssdad.com%2Flr%2F&ie=utf-8&oe=utf-8&aq=t&rls=com.ubuntu:en-US:unofficial&client=firefox-a" '>
    <'/os:Url'>

    <'/SearchPlugin '>
  5. The last line needs a little explanation, but the rest of them are self-explanatory. I had just copy and pasted the url that google throws up when I enter a search term like "blah blah site:www.ssdad.com".
  6. And the search terms position is filled with the keyword {searchTerms}. Like this, http://www.google.co.in/search?q={searchTerms}+
I have included a ' with every < to prevent browser from interpreting it as HTML code. Remove them before copying.

No comments:

OK GOOGLE on Samsung Galaxy S7 doesn’t work

To make Ok Google detection work on Galaxy S7 (Galaxy series phones) we need to perform a couple of steps. 1. As long as Samsung S vo...