Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Add extension to firefox as default

Overview

I am building a rpm containing my custom config files for myself. In the course of doing so, I wanted to add an extension to firefox because I want to use it all the time. I wanted an extension to be automatically installed in Firefox for a new user profile. I had to go learn how to do it. This document shows how to do just that.

Add extension to firefox as default in GNU/Linux

You need to get the extension ID of the extension. You can get the extension id by opening the xpi file in an archive opener (on xfce I used the default Xarchiver) and examining install.rdf. The tag is . Name the file "tag.xpi," e.g., "{52c2877e-44e1-11e5-8874-a62d1d5d46B0}.xpi." Place this file in /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/ directory. Chmod to 0644 and chown root:root.

How not to do it

I started this task for Firefox actually as a way to have all my settings made available, similar to what this person does: https://github.com/jamielinux/securemymozilla. I eventually made my way to what extensions I want to have present (because the Korora guys can do it). So I started looking at ~/.config. Well, I learned Firefox uses ~/.mozilla/firefox/. I eventually learned that Korora installs its default firefox extensions (xclear and uBlock origin) to /usr/share/mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/ directory. There was a weird hashed extension (extension being a .xpi file I remember from a decade ago, in my Windows days, so I know what they are), as well as two named xpi files: xclear and uBlock. I eventually figured out (by using Firefox to try to open) the hashed file: It was the default firefox theme. I downloaded the xpi file of my choice (Remove It Permanently) but I couldn't get it to actually load in a new firefox profile. You can force a new firefox profile by deleting ~/.mozilla/firefox/profiles.ini and ~/.mozilla/firefox/987654321.default/.

References

Weblinks

  1. Useful for other customization of firefox https://developer.mozilla.org/en-US/Firefox/Enterprise_deployment
  2. Most helpful, from search "Linux add default extension to firefox" https://developer.mozilla.org/en-US/Add-ons/Installing_extensions
  3. Interesting but didn't use https://mike.kaply.com/2010/08/05/creating-a-customized-firefox-distribution/
  4. Also interesting but not helpful here https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Customizing_Firefox
  5. Pointed me in the right direction https://github.com/kororaproject/kp-mozilla-xclear/blob/master/build/mozilla-xclear.spec
  6. Cool project that inspired me https://github.com/jamielinux/securemymozilla

People

Korora developers in #korora irc channel on freenode

Comments