How to package Firefox and Chrome extensions

2020-08-02 00:10发布

问题:

I am new to Firefox and Chrome extension development.

I have downloaded and tested helloworld sample extension in both FF and Chrome in development mode.

Followed the following steps to work properly in FF and chrome,

  • In FF

    1. Extracted the sample extension, and added one file in /mozilla/firefox/dev_user/helloworld@mozilla.doslash.org and given extracted folder path.

    2. My FF version is 12.0 and I changed the<em:maxVersion> to 12.0.* in install.rdf file.

    3. Restarted FF and tested, it worked fine.

  • In Chrome:

    1. Extracted the sample extension

    2. Choose Tools > Extensions

    3. Checked Developer mode

    4. Click the Load unpacked extension button

    5. Dialog appears and selected extracted sample extension folder path

    6. Extension is added and works perfectly.

Now I would like to know how to package these extensions? I mean on clicking the package that extension should install directly in the browser instead of following the above steps.

回答1:

It's generally not a good idea to ask four questions at once. Let's try to answer all your questions:

How do I package a Firefox extension?

You follow the official documentation (a Firefox XPI package is simply a ZIP archive).

How do I package a Chrome extension?

You follow the official documentation.

How do I make sure a Firefox extension can be installed from a website?

That question is already answered elsewhere.

How do I make sure a Chrome extension can be installed from a website?

You cannot. Current Chrome versions make it very complicated to install extensions from third-party sites. Your best bet is to upload your extension to the Chrome Web Store (as a ZIP archive of extension files, not a proper package - Chrome Web Store creates the package for you). Once the extension is in the Chrome Web Store you can use inline installation to simplify installation from the website associated with your extension.