Firefox extension .xpi file structure: description, contents, creation, and installation -


i put lot of stuff in searching easy way develop firefox extension, unable create extension. kindly tell me file structure of firefox extensions , easy way install extension.

.xpi file format (extension packaging)

the .xpi files used containers mozilla (firefox, thunderbird, etc.) extensions merely zip archives have had file extension changed .xpi files added archive using either "deflate" compression, or uncompressed. if use other type of compression, other "deflate", or "store" (uncompressed), error like:

this add-on cannot installed because appears corrupted 

the files start in root directory of zip compressed archive (i.e. there not empty first level directory contains files).

the contents of archive few files number of files. files must included depend on type of add-on packaging. if planning on using add-on sdk, don't need know format these files, of abstracted using jpm tool. if have no idea talking about, may want read on different types of add-ons firefox (webextensions, add-on sdk, bootstrap/restartless, , overlay/legacy/xul).

webextensions:

at minimum, have manifest.json file describes extension. will, certainly, have additional files. chrome.manifest, install.rdf, , package.json files used in other types of add-ons not used in webextension add-ons. should not have files.

add-on sdk:

the .xpi file firefox add-on sdk extension should created executing jpm xpi. add-on sdk extensions described in package.json file. when run jpm xpi add-on translated being bootstrap/restartless add-on. done translating package.json file install.rdf, creating chrome.manifest file , adding wrappers javascript. should not try perform process yourself, unless doing necessary add-on function (which quite rare).

bootstrap/restartless , overlay/legacy:

at minimum, have install.rdf, , chrome.manifest files. bootstrap/restartless add-ons have bootstrap.js file. there additional files. these types of add-ons not use package.json, nor manifest.json.

my simple bootstrap/restartless extension, print button print (changes print button print instead of print preview), has following structure:

archive contains:   bootstrap.js   chrome/   chrome/content/   chrome/content/options.xul   chrome/skin/   chrome/skin/printer-typec128.png   chrome/skin/printer-typec32.png   chrome/skin/printer-typec48.png   chrome/skin/printer-typec64.png   chrome.manifest   install.rdf   license.txt total 12 entries (42360 bytes) 

creating .xpi file

you can use whatever method desire create .zip file, renamed .xpi. keep in mind requirement compression method supported "deflate", files can added archive uncompressed. top level files (e.g. ever have of manifest.json (webextensions), or else: chrome.manifest, , install.rdf) should in root directory of archive, not in subdirectory.

to create .xpi file use batch file, uses combination of dos , unix/linux (actually cygwin) commands:

mkxpi.bat:

rm -f printbuttonisprint@makyen.foo.xpi zip -1 -r printbuttonisprint@makyen.foo.xpi * -x@xpi.ignore pause 

this removes old version of .xpi file. creates new .xpi file using, -1, minimal compression (speed of access more important saving space), forces storing uncompressed or using "deflate". new .xpi contain files , subdirectories *, ignoring files in xpi.ignore text file (-x@xpi.ignore). ignoring files used because have other things in directory (e.g. .git directory, .bak files auto-created editor, etc.). once .xpi file created script executes pause can verify files included, there no errors, etc., instead of having window disappear , assuming fine.

my xpi.ignore file bit long, accumulates cruft various projects , cleaned out:

*.com *.class *.dll *.exe *.o *.so *.7z *.dmg *.gz *.iso *.jar *.rar *.tar *.zip *.log *.sql *.sqlite *.svg */.ds_store */.ds_store? */._* ._* */.spotlight-v100 .spotlight-v100 */.trashes .trashes */ehthumbs.db */thumbs.db *.orig *.bak *old* old/* */old/* *.old *.old[0-9] */old/* */old[0-9]/* *.unknown *.unknown[0-9] *.updated *.updated[0-9] */copy * */old */old* */old[0-9] */old[0-9][0-9] */test/* */not in xpi/* */tmp *.tmp */foo *.foo *checkpoint .git */.git .gitignore */.gitignore xpi.ignore mkclean.bat mkclean.bat.dontrun mkxpi.bat *.xpi */devtools-toolbox-window.ico */devtools-webconsole.ico */jsconsolewindow.ico */main-window.ico */places.ico */viewsource.ico 

installing extensions

as normal extensions:
in order install extension normal add-on branded release or beta version of firefox must signed mozilla. done submitting amo. can install unsigned extensions normal add-ons other versions of firefox (e.g. firefox developer edition, firefox nightly, unbranded beta, or unbranded release) setting xpinstall.signatures.required false in about:config.

if choose, in particular installation of firefox, can disable add-on signing requirement. more information, can see answer: how can disable signature checking firefox add-ons?

installing extension (i.e. .xpi file) can simple matter of dragging , dropping onto firefox window running profile in desire installed. development/testing, can have extension in directory on local drive using firefox extension proxy file (create file named extension's <em:id> (in install.rdf bootstrap/restartless , overlay/legacy) in profile's extensions directory containing 1 line complete path directory containing extension's files). depending on goal (one profile, profiles, users, os, etc.), there other options how install extensions.

as temporary add-ons:
type of extension can not installed temporary add-on overlay/legacy. such extensions require browser restarted after install prior being functional. such, can not temporary.

to install extension temporary, navigate about:debugging. page, click on load temporary add-on, navigate popup appropriate folder , select either .xpi file, or file in directory. if select file other .xpi file, assumed directory contains unpacked add-on files automatically identified.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -