How to publish my WebExtension my own

Hi,

I want to publish my extension using my own installer. I have my signed xpi file. But how i should install using my installer. Earlier i use to copy my manifest.json and other files to %appdata%/Mozilla\Extensions{ec8030f7-c20a-464f-9b0e-13a3a9e97384} folder. But not sure how to use xpi file now.

Regards,
Sandeep

Here is how I do it on macOS.

My installer prompts the user to run Firefox in the desired profile, and then click a “OK” button; also it tells the user that after they click the “OK” button, Firefox will activate and prompt them in a popover to install the extension. When they click the “OK” button, my installer “opens” the .xpi file in the currently-running Firefox instance using the macOS NSWorkspace open(_:withApplicationAt:options:configuration:) function. I’m sure that other platforms have a similar API.

It is true that, until 2-3 years ago I just copied the files into place as you did, without even prompting the user, relaunched Firefox, and that worked.

Is there a way that i can copy my xpi file for WebExtension and once firefox loaded after my installation(msi) and recognize new WebExtension

If your installer is a native application, theoretically, yes. Because Firefox is a native application, you could reverse-engineer, and/or study Firefox’ open source code, and spoof whatever Firefox does when the user approves an extension. In addition to copying your files into the profile folder, you will probably need to add objects to the prefs.js file. But there may be more to it than that. And whatever you do would be completely unsupported and subject to breakage in any new Firefox version. Finally, your installer would probably need to first quit Firefox if it is running, before so messing with its files. So if your purpose is to make the installation seamless and unnoticed by the user, you’ll be wasting a lot of development time.

Unless your purpose is a hacking challenge, I recommend instead doing it above board, as I described in my original reply :slight_smile:

I found the solution on following link.

In Firefox 4 you may also just copy the extension’s XPI to the directory and name it .xpi as long as the extension does not require extraction to work correctly. If it needs to be extracted/unpacked then you should find a line in the install.rdf file that defines unpack as true (e.g. em:unpacktrue</em:unpack>). All WebExtensions based add-ons do not require being unpacked.

Thanks and Regards,
Sandeep

Thank you for digging that document up, Sandeep. Obviously, you are correct that this method of installing extensions is currently supported. However, that document was outdated, mixed up due to partial edits, and was missing some important information. After doing some experiments, I edited the document – at least in my opinion, it makes sense now :slight_smile:

Conclusion: There are advantages and drawbacks to this method, compared with the open the XPI method which I described in my previous post. Developers should read and consider which gives a better user experience for their application.

1 Like

That is really cool! :smiley: