firefox擴展和chrome擴展非常相似,甚至兼容。因總結過chrome擴展的開發,這里不提,本篇談談firefox擴展的安裝。
1、打包
所謂的打包,就是壓縮,利用普通的右鍵壓縮文件夾,這樣形成的zip包,沒法簽名。firefox的打包可以用命令:web-ext build。要執行此命令,必須安裝web-ext,它是基於node.js的。所以首先得安裝node.js。可參考文章: Getting started with web-ext。
2、簽名
upload your add-on through the Developer Hub on AMO 上傳壓縮包到開發中心進行簽名。當然,簽名還有其它兩種方式,我覺得比較麻煩。可參考文章:Signing and distributing your add-on。
3、分發
簽名后會生成一個后綴名為xpi的文件。
- Direct the user to install from addons.mozilla.org (AMO) by offering a link.
- Sideloading.
- Using the Windows registry.
有三種安裝方式:
a、把xpi文件上傳到官方的插件中心,然后給用戶提供一個連接。
b、xpi文件下載到本地后,從瀏覽器安裝。打開擴展列表,如下圖所示:
還有一種方式,就是把文件重命名為插件的Id,然后放到插件加載的默認位置,瀏覽器重啟后即可加載。可參考:Sideloading add-ons。
c、用注冊表
For all users of the computer, add to the following registry keys:
HKEY_LOCAL_MACHINE\Software\Mozilla\Firefox\Extensions
or
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Mozilla\Firefox\Extensions
然后創建項,名稱為插件Id,如borderify@example.com,值為路徑,如 c:/webext/borderify@example.com.xpi
可參考:
Add-ons in the enterprise