Tuesday, March 20, 2018

Adding a Custom search URL to your firefox browser

It is a very common that we have a website which we enter a search term regularly to get response back. Instead of going to website and use its search feature, we can directly route that search to website via FF search.

So, how to make that work?

First read up on the link here which details the process : https://developer.mozilla.org/en-US/docs/Talk%3ACreating_OpenSearch_plugins_for_Firefox

Then create two files one .htm and another .xml . You open the .htm file in browser and the search icon changes with a +, indication a search engine is available on website to be added to browser.

Now ,if the files are on you local laptop, the url localhost won't work, Also, FF blocks file:/// urls, so what to do?  Simplest way it to run a local webserver, you can do it variety of way, one of way is to just run  local webserver from the directory where these files are contained: Example using python:

python -m SimpleHTTPServer
(for v3) python -m http.server [<portNo>]


Example of .htm

<html>
    <head>
        <link rel="search"
      type="application/opensearchdescription+xml"
      title="YOURWEBSITE"
      href="http://localhost:8000/YOURWEBSITE.xml">
        YOURWEBSITE
        </link>
    </head>
</html

Example of .xml; replace with your own URL, and customize accordingly.

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
     <ShortName>YOURWEBSITE</ShortName>
     <Description>YOURWEBSITE)</Description>
     <Image width="16" height="16">data:image/x-icon;base64,R0lGODlhEAAQAOMAAAAAABgYtRgYrRgYlBBSMcaEMQhKKTFaKcZ7Mb17MRBKKYxzKQAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARGEMhAq7y36iBwphjXhaAnnKR3DUOqAqyrxt8Lt18w05fAYawBQeULBguGA9E4MCASB4XtYnAuDsopoJqASrVVBMKglVSrEQA7</Image>
     <InputEncoding>UTF-8</InputEncoding>
     <Url type="text/html" method="get" template="https://YOURWEBSITE.com/xyzurl/name?searchName={searchTerms}"/>
</OpenSearchDescription>



That's it to it you got your search engine available on FF. Enjoy!

No comments: