New solution (since the previous one does not work anymore):
Now if you visit a website like Twitter, Firefox will let you add the Twitter search easily (https://support.mozilla.org/en-US/kb/add-or-remove-search-engine-firefox). But in case you want to add another website that is not supported, you will need a web server like Apache.
Below would be the solution for Twitter in case they don't use the search engine file opensearch.xml
anymore.
Create a file, for example twitter_search.htm
(this HTML source code is used on twitter.com, I just removed the /
before opensearch.xml
):
<link rel="search" type="application/opensearchdescription+xml" href="opensearch.xml" title="Twitter">
Then create another file, with the same name used in the href parameter of the previous HTML code, for example opensearch.xml
with this content (this XML source code is used at https://twitter.com/opensearch.xml):
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>Twitter</ShortName>
<Description>Twitter Search</Description>
<Url type="text/html" method="get" template="https://twitter.com/search?q={searchTerms}"/>
<Image width="16" height="16">https://abs.twimg.com/favicons/favicon.ico</Image>
<InputEncoding>UTF-8</InputEncoding>
<moz:SearchForm>https://twitter.com/search-home</moz:SearchForm>
</OpenSearchDescription>
If needed, customize these files to replace the search URL, search form URL, name, description and icon. Put these 2 files in a folder of your web server and open the HTML file that you can find by visiting http://localhost in your web browser. You will be able to add your custom search engine to Firefox.
Previous solution (not working anymore):
Here is how I restored the Twitter search engine for Firefox, which seems to have been removed in Firefox 78 (you could create a search for other websites also based on this answer):
I tested with the Linux version of Firefox (Ubuntu package) but it should work with any operating system by creating the distribution
folder / subfolders and search plugin file (https://wiki.mozilla.org/Mobile/Distribution_Files).
In my profile folder .mozilla/firefox/xxx.default/
, there was a file search-metadata.json
that contained a link to a non-existing file /usr/lib/firefox/distribution/searchplugins/locale/en-US/twitter.xml
.
So I created this file with the following content (based on the documentation https://developer.mozilla.org/en-US/docs/Mozilla/Creating_MozSearch_plugins and search plugins already present https://packages.ubuntu.com/focal/amd64/firefox/filelist):
<?xml version="1.0" encoding="utf-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Twitter</ShortName>
<Description>Twitter Search</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image height="16" width="16">data:image/x-icon;base64,
AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAQAAAAAAAAAAAAAAAAA
AAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A////AP///wD///8A////AP///wD///8A////AP///wz///8f////H////x////8Y////B///
/wD///8A////AP///wD///8A////AP///wD///8A////A////yj7789g9tV+ofbVfqH21X6h+N+e
ifz03lf///8o////A////wD///8A////AP///wD///8A////APr37g/PsGCftogQ7r2JAP/bnwD/
7qwA/+6sAP/urAD/9Mtftv357z////8D////AP///wD///8A////AP///wD///8A////AP///w/5
7c5a88VQwu6sAP/urAD/7qwA/+6sAP/xvDDb/fnvP////wD///8A////AP///wD///8A////AP//
/wDz5L5X7bgv2+6sAP/urAD/7qwA/+6sAP/urAD/7qwA//G8MNv///8Y////AP///wD///8A////
AP///wD///8M9NN+n+6wD/PurAD/7qwA/+6sAP/urAD/7qwA/+6sAP/urAD/9Nyegf///wD///8A
////AP///wD///8A+O3PVu6wD/PurAD/7qwA/+6sAP/urAD/7qwA/+6sAP/urAD/7qwA//G8MNv/
//8A////AP///wD///8A////ANasQMXurAD/7qwA/+qpAP/YnAD/1JkA/+6sAP/urAD/7qwA/+6s
AP/urAD/////FP///wD///8A////AP///wDz255+7qwA/9icAP+6ixDuz7Bgn9m8b5TurAD/7qwA
/+6sAP/urAD/7qwA//jkr3j///8M////AP///wD///8A47Y/ysmRAP/PsGCf+vfuD////wDw584w
46QA/+6sAP/urAD/7qwA/9+hAP/orA/z9OrPQv///wD///8A////AMypT7Hhz55g////AP///wD/
//8A////AMOaL9DMlAD/0JYA/8mRAP/FoEC/vpIf4OPQnmL///8A////AP///wD69+4P////AP//
/wD///8A////AP///wD69+4P3ceOcNi/foHhz55g////APr37g/69+4P////AP///wD///8A////
AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A
////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD/
//8A//8AAP//AAD//wAA8P8AAMA/AAD4HwAA8A8AAOAHAADgBwAAwAcAAOAHAADHAwAA3wMAAP/f
AAD//wAA//8AAA==</Image>
<Url type="text/html" method="get" template="https://twitter.com/search?q={searchTerms}"/>
</OpenSearchDescription>
To get the Base64 of the latest Twitter icon that you can see above, I downloaded https://twitter.com/favicon.ico and used the Linux command base64 favicon.ico
.
The following files were present in my profile folder but were not needed anymore so I removed them to avoid potential conflicts (you can backup files in case you want to reuse them): search-metadata.json
, search.json
, search.json.mozlz4
.
The following answers did not work for me but contained useful information:
https://stackoverflow.com/questions/9963256/adding-a-custom-search-engine-to-firefox/10034461#10034461
https://stackoverflow.com/questions/9963256/adding-a-custom-search-engine-to-firefox/40651019#40651019