Install WebExtensions on Firefox from the command line - firefox

I found the question How to install Firefox addon from command line in scripts? that seems to work for Firefox extensions (i.e. ones with an install.rdf file) but what about WebExtensions (extension with a manifest.json file instead)?

Please see:
Installing extensions
Customizing Firefox: Including extensions with your distribution of Firefox
The question you link on askubuntu: How to install Firefox addon from command line in scripts? is several years out of date, but does have some good information.
At this point, most Mozilla add-ons, including all Firefox WebExtension add-ons, are installed manually by placing the add-on's .xpi file in the appropriate directory with the correct name for the extension without unpacking (unzipping) the contents. [You can also install them by downloading them in Firefox, drag-and-drop the .xpi onto Firefox/Thunderbird, etc.]
You can determine those add-ons that must be unpacked by unpacking the add-on's .xpi file and looking at the install.rdf file to see if it has <em:unpack>true</em:unpack>. All WebExtensions don't have this file and are installed without unpacking.
The .xpi file must be called [extensionID].xpi. You can find the extension ID from either the install.rdf file (non-WebExtension add-ons). In that file, you are looking for <em:id>ThisEntireStringIsTheAddOnsID</em:id>
For a WebExtension, the ID is in the manifest.json file under the applications property:
"applications": {
"gecko": {
"id": "ThisEntireStringIsTheAddOnsID"
}
},
For both of the above examples the .xpi file must be renamed to ThisEntireStringIsTheAddOnsID.xpi
If the install.rdf file includes <em:unpack>true</em:unpack>, then the files in the .xpi must be unpacked (unzipped) and placed in a subdirectory under the extensions directory. In the above install.rdf example (again WebExtensions are not unpacked), the directory would be named: ThisEntireStringIsTheAddOnsID
Extension directories:
The extension directories where you put the .xpi file or unpacked directory are (information partially copied from MDN):
For all users running a particular version of Firefox:
[Firefox install directory]/browser/extensions/
Firefox will ask the user to confirm installation of the add-on when that version of Firefox is run. The user will not have the ability to remove the extension, only disable it. The extension will not be automatically updated.
For all users running a particular version of Firefox:
[Firefox install directory]/distribution/extensions
The extension will be installed for all users/profiles the first time the profile is run with that version of Firefox. The extension will be copied into the profile's extensions directory and the user will be able to remove it in addition to disabling it. The user will not be asked to confirm installation. The extension copied to each profile will be automatically updated along with all other extensions installed for that profile. You should not unpack any .xpi files in this directory. If the file needs to be unpacked, it will be done automatically by Firefox when the extension is installed in each profile.
For a particular User's specific profile:
[profile directory]/extensions/
On Windows:
All profiles for a specific user:
<I>%appdata%\\Mozilla\\Extensions\\{ec8030f7-c20a-464f-9b0e-13a3a9e97384}\</I>
Profile directories are located at:
<i>\\Mozilla\\Firefox\\Profiles\\*</i>
OSX:
For all users:
/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Just for a specific user, place it in that user's library folder hierarchy:
~/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Linux:
For all users:
/usr/lib/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
or
/usr/lib64/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
or
/usr/share/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Just for a specific user:
~/.Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
NOTE:
The -install-global-extension option mentioned in the question/answer you linked was removed from Firefox as of Gecko 1.9.2 ( a long time ago).

Related

Install firefox addon programmatically [duplicate]

I found the question How to install Firefox addon from command line in scripts? that seems to work for Firefox extensions (i.e. ones with an install.rdf file) but what about WebExtensions (extension with a manifest.json file instead)?
Please see:
Installing extensions
Customizing Firefox: Including extensions with your distribution of Firefox
The question you link on askubuntu: How to install Firefox addon from command line in scripts? is several years out of date, but does have some good information.
At this point, most Mozilla add-ons, including all Firefox WebExtension add-ons, are installed manually by placing the add-on's .xpi file in the appropriate directory with the correct name for the extension without unpacking (unzipping) the contents. [You can also install them by downloading them in Firefox, drag-and-drop the .xpi onto Firefox/Thunderbird, etc.]
You can determine those add-ons that must be unpacked by unpacking the add-on's .xpi file and looking at the install.rdf file to see if it has <em:unpack>true</em:unpack>. All WebExtensions don't have this file and are installed without unpacking.
The .xpi file must be called [extensionID].xpi. You can find the extension ID from either the install.rdf file (non-WebExtension add-ons). In that file, you are looking for <em:id>ThisEntireStringIsTheAddOnsID</em:id>
For a WebExtension, the ID is in the manifest.json file under the applications property:
"applications": {
"gecko": {
"id": "ThisEntireStringIsTheAddOnsID"
}
},
For both of the above examples the .xpi file must be renamed to ThisEntireStringIsTheAddOnsID.xpi
If the install.rdf file includes <em:unpack>true</em:unpack>, then the files in the .xpi must be unpacked (unzipped) and placed in a subdirectory under the extensions directory. In the above install.rdf example (again WebExtensions are not unpacked), the directory would be named: ThisEntireStringIsTheAddOnsID
Extension directories:
The extension directories where you put the .xpi file or unpacked directory are (information partially copied from MDN):
For all users running a particular version of Firefox:
[Firefox install directory]/browser/extensions/
Firefox will ask the user to confirm installation of the add-on when that version of Firefox is run. The user will not have the ability to remove the extension, only disable it. The extension will not be automatically updated.
For all users running a particular version of Firefox:
[Firefox install directory]/distribution/extensions
The extension will be installed for all users/profiles the first time the profile is run with that version of Firefox. The extension will be copied into the profile's extensions directory and the user will be able to remove it in addition to disabling it. The user will not be asked to confirm installation. The extension copied to each profile will be automatically updated along with all other extensions installed for that profile. You should not unpack any .xpi files in this directory. If the file needs to be unpacked, it will be done automatically by Firefox when the extension is installed in each profile.
For a particular User's specific profile:
[profile directory]/extensions/
On Windows:
All profiles for a specific user:
<I>%appdata%\\Mozilla\\Extensions\\{ec8030f7-c20a-464f-9b0e-13a3a9e97384}\</I>
Profile directories are located at:
<i>\\Mozilla\\Firefox\\Profiles\\*</i>
OSX:
For all users:
/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Just for a specific user, place it in that user's library folder hierarchy:
~/Library/Application Support/Mozilla/Extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Linux:
For all users:
/usr/lib/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
or
/usr/lib64/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
or
/usr/share/Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
Just for a specific user:
~/.Mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}/
NOTE:
The -install-global-extension option mentioned in the question/answer you linked was removed from Firefox as of Gecko 1.9.2 ( a long time ago).

Install Firebug Extension Manually

I want to install Firebug manually and update configuration settings on my own. I followed below steps:
Downloaded firebug-2.0b1.xpi file (3 MB)
Extracted the content by using winRAR.
put this extracted folder "firebug-2.0b1" inside "C:\Program Files\Mozilla Firefox\extensions"
Now, I run Firefox, but It seems firebug is not installed. This doens't work because some configurations are not done or Profile is not updated. I could like to know if any changes I need to do in folder.
I am doing this because, I couldn't install by drag & drop .xpi file on firefox or install through browser itself.
To install Firebug manually you have to do it differently. There are two ways to run extensions manually:
1. Extract the XPI
Download the XPI file that contains the extension
Locate the 'extensions' folder within your profile (e.g. via Firefox menu > Help > Troubleshooting Information > Show Folder)
Create a new folder within the 'extensions' folder and call it like the add-on's id (for Firebug this is firebug#software.joehewitt.com)
Extract the XPI into that folder
2. Get the sources from the git repository
A detailed description for how to do that can be found on the development setup description on the Firebug wiki. It's similar to the description above with the addition that you'll be able to always get the latest sources.
Two notes:
The folder name must be the same as the addon's ID (look in install.rdf of the addon) In your case it's not firebug-2.0b1 , but firebug#software.joehewitt.com
The directory where the addon should be placed is not where the
Firefox itself is installed, but into your Firefox's profile. By default it's in %APPDATA%\Mozilla\Firefox\Profiles\XXXXX\extensions\ (where XXXXX is name of your profile folder. More info about profiles you can find here)

Unzipping and zipping a working .xpi makes it stop working

I downloaded the basic Hello World xpi from Mozilla, and it installed in my Firefox without any problems. Then I unistalled the addon, unzipped the xpi, then, without changing anything inside it, zipped it again using 7zip. I tried to install it, and Firefox gave me a "This addon could not be installed because it appears to be corrupt" error.
Unzipping the .xpi produces a folder with the same name as the .xpi, with its contents. To create a working .xpi, zip the contents of that folder, not the folder itself.
Credit goes to nmaier.

What file permissions are needed in an XPI?

I recently received the following comment from the reviewer of one of my add-ons at the official Mozilla Add-ons website:
The permissions in your XPI are broken. Most files and directories do not have the expected read and execute permissions, or indeed any permissions at all.
I wasn't aware that file permissions were an issue in XPI files. To my knowledge, none of the files in my XPI need the execute bit set (I only package standard stuff: XUL, JavaScript, CSS, etc). I create my XPI in Windows using the Cygwin zip tool, and since Windows knows nothing about file permissions, they aren't stored as they would be in Linux.
What file permissions are expected for file and directory entries in an XPI? The Extension Packaging page at MDN has the following quote, but no associated details on what they should be:
... you must verify that the file system permissions for the directories and files for the extension are set properly. Otherwise, the Extension Manager may not function properly with the extension or the extension itself may not work properly.
This is typically an issue if you create the extension package on Windows but the extension is used on Linux or OS X later - Windows doesn't have any file permissions to be put into a ZIP archive and unpacking on Linux or OS X sometimes creates bogus file permissions (000 rather than the usual 755 or 644). You could try using a different ZIP packer, e.g. Info-ZIP that doesn't cause such issues for me. Better yet, don't require your extension to be unpacked at all - <em:unpack> is often used but rarely really required.

Upgrade to Mozilla Firefox 20 and Selenium IDE 2.0.0 - path for user-extensions.js has changed?

I recently upgraded to firefox 20, and upgraded selenium IDE to 2.0.0
I have a custom "user-extensions.js" file that I usually put here:
C:\Users\skyn\AppData\Roaming\Mozilla\Firefox\Profiles\1dj9c5sr.default\extensions{a6fd85ed-e919-4a43-a5af-8da18bda539f}\chrome\content\selenium-core\scripts
Only now, with Firefox 20, the directory structures have changed apparently.
Here is the path that exists:
C:\Users\skyn\AppData\Roaming\Mozilla\Firefox\Profiles\ug1917fp.default\extensions
and then instead of the next directory in the path, there is an xpi file (with same name):
{a6fd85ed-e919-4a43-a5af-8da18bda539f}.xpi
What happened to the directory and everything in it?
I can't say I understand the way Mozilla organizes its data. Did it install correctly?
This is a issue with the new firefox. It doesn't expand .XPI files automatically.
Take a look at https://developer.mozilla.org/en-US/docs/Extension_Packaging
Starting in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1),
XPI files are no longer unpacked when extensions are installed.
Instead, the XPI itself is placed in the extensions directory, and
files are loaded directly out of the package.
Farther down it says:
A customized application can include add-ons (including extensions and
themes) by placing the unpacked (that is, not the XPI files, but the
packages' contents) in the <appdir>/distribution/bundles directory.
The directory containing the add-on must be named the same as the ID
of the add-on or theme. Add-ons packaged in this way will not be
visible to the user.

Resources