📜 ⬆️ ⬇️

Create a search plugin for Firefox

Firefox quite simple methods allows you to add new search engines. Although there is already a large selection of them on the Mozilla website, but still there is not everything. In this case, you can add the plugin yourself.
So initially for this we need a template. For GET requests this will do:
< SearchPlugin xmlns = " www.mozilla.org/2006/browser/search " xmlns: os = " a9.com /-/ spec/opensearch/1.1 " >
< os: ShortName > </ os: ShortName >
< os: Description > </ os: Description >
< os: InputEncoding > UTF-8 </ os: InputEncoding >
< os: Image width = "16" height = "16" > data: image / x-icon; base64, </ os: Image >
< os: Url type = "text / html" method = "GET" template = "" >
</ os: Url >
</ SearchPlugin >

Now fill it. For example, I will make a plugin for requests for Whois service nic.ru:
  1. In the ShortName tag we write a short name, it will be indicated in the search string and in the list of plugins
  2. In the Description tag we specify the description of the plugin.
  3. In the Image tag, we need to write an icon encoded using base64 (since we cannot write binary data to xml files) for this:
    1. First we get an icon (it can be done in several ways, for example, download favicon from the site or do it yourself and save it in bmp format 16x16)
    2. Now, using the wonderful openssl toolkit, we encode the data in base64 format: the command will look like this “openssl enc -base64 -in favicon.ico”
    3. All the output of the openssl command is copied to the Image tag after the line "data: image / x-icon; base64,"
  4. In Url, in the template attribute, specify the pattern string to search for:
    1. To do this, go to the site
    2. We write any query, for example, to search "12345678"
    3. The search string shows that the search pattern looks like this: “ www.nic.ru/whois/?query= ” and at the end our term is added
    4. In the template, specify the url of the request, and instead of the query string, we write {searchTerms}
As a result, we obtain:
< SearchPlugin xmlns = " www.mozilla.org/2006/browser/search " xmlns: os = " a9.com /-/ spec/opensearch/1.1 " >
< os: ShortName > NIC WhoIS </ os: ShortName >
< os: Description > WhoIS service </ os: Description >
< os: InputEncoding > UTF-8 </ os: InputEncoding >
< os: Image width = "16" height = "16" > data: image / x-icon; base64,
AAABAAEAEBAAAAEAGABoAwAAFgAAACgAAAAQAAAAIAAAAAEAGAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAD //////////////////////// 379 / v3r / v3r / 79 + //////
/////////////////////////////////// gvX / JjB / BfADBfADBfADBfADMlC / o
zp ///////////////////////// 379 / MlC / BfADBfADBfADBfADBfADBfADBfADB
fADQnD / 79 + /////////// 9 + / fkxY7gvX / YrWDUpFHgvX / gvX / kxY / hwofFhBfB
fADBfADMlC / 79 + ///////// k8v2Xy / ev2Pn05s / 05s + v2PmXy / fK5fv //////// w
3r / FhBfBfADgvX ///// 58ubX6 / w0mfA / n / H /////// 8 / n / E0mfDK5fvy48j47t //
/// 05s / BfADFhA / 79 + / iwYr /// 80mfA0mfDk8v3X6 / w0mfA0mfD //// JjCXBfAD7
9 / D //// YrWDBfADozp / UpU / 47t9ksfQ0mfC93vqKxfc0mfBwuPX9 + vXBfADBfADj
xY ///// nzp / BfADgvX / QnD / r1q6Kxfc0mfA0mfA0mfA0mfCj0vj //// UpFHBfADY
rWD //// 05s / BfADgvX / YrV / gvX + j0vg0mfBhsPS12vphsPQ0mfCXy / f47t / BfADM
lDP //////// BfADgvX / kxY / UpFHK5fs0mfBstvT //// x9vk0mfA / n / H //// JjCXB
fAD //////// QnULs1q / 379 / JjCX /// 80mfA0mfCKxfdisfQ0mfBLpPL9 + / fBfADB
fADw3r ///// euXf //////// ctW / 79 / BYrPM0mfA0mfBLpPJ9v / a93vrq1KrBfADB
fADctW / w3r / t27j //////////// z48v ////////// 79 / Dnzp / UpFHFhBfBfADB
fADBfADYrV /////////////// 79 + / UpU / BfADBfADBfADBfADBfADBfADBfADB
fADctW ///////////////////////////// v3r / UpU / FhA / BfADBfADJjB ​​/ YrV / v
3r //////////////// 8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA </ os: Image >
< os: Url type = "text / html" method = "GET" template = " www.nic.ru/whois/?query= {searchTerms}" >
</ os: Url >
</ SearchPlugin >

All this must be saved as an xml file, for example, nic-whois.xml and copied to the searchplugins folder of your profile:
For Linux users, this will be "~ / .mozilla / firefox / xxxxxxxx.default / searchplugins"
For Windows users, "% USERPROFILE% \ Application Data \ Mozilla \ Firefox \ Profiles \ xxxxxxxx.default \ searchplugins"
xxxxxxxx is the name of your profile, it all has a different meaning.
That's all.

Here (! Warning eng) you can read about the same, but in more detail.

')

Source: https://habr.com/ru/post/28133/


All Articles