Is it possible to decode a Firefox addon from XPI to XUL?
Asked Answered
S

3

7

Is it possible to decode a firefox addon from the XPI binding format to the native language XUL?

I am just trying to learn how to make a addon. So, I think if I can decode a Firefox addon then I can learn addon architecture!

Sirrah answered 28/4, 2011 at 16:30 Comment(2)
You could look for an addon whose source is readily available.Subnormal
Or read the documentation.Consequence
C
5

Most of the code that you will want to look at is in the extension's chrome directory, usually in a jar file. All you need is a file extractor that can extract zip files. Once you extract the xpi (it's just a zip file with an xpi extension), open the chrome subfolder and see what's there. If it's a jar file, extract it's contents (.jar files are also just zip files with a different extension). From there, there's probably a content folder, which should have most of the xul, css, js, etc.

Cicero answered 7/5, 2011 at 16:51 Comment(1)
Ah, my bad; jar files are also just zip files. Just rename it to .zip and use an unzip app.Cicero
A
11

XPI is simply put a ZIP file, so you can just extract its contents and read the files...

Arithmetician answered 28/4, 2011 at 16:45 Comment(0)
C
5

Most of the code that you will want to look at is in the extension's chrome directory, usually in a jar file. All you need is a file extractor that can extract zip files. Once you extract the xpi (it's just a zip file with an xpi extension), open the chrome subfolder and see what's there. If it's a jar file, extract it's contents (.jar files are also just zip files with a different extension). From there, there's probably a content folder, which should have most of the xul, css, js, etc.

Cicero answered 7/5, 2011 at 16:51 Comment(1)
Ah, my bad; jar files are also just zip files. Just rename it to .zip and use an unzip app.Cicero
H
3

Just learned there is also xpi-unpack and corresponding xpi-pack in Ubuntu (via sudo apt-get install mozilla-devscripts); seems to take unpacking of both .xpi and included .jar files into account..

Cheers!

Edit: note however, you may have permission problems with xpi-unpack; here's an example command line log I had:

user@PC:Desktop$ xpi-unpack colt.xpi colt-dir
Unpacking colt.xpi
Unpacking ./chrome/colt.jar
Unpacked xpi file.
user@PC:Desktop$ ls -la colt-dir/chrome/colt.jar\!/
total 16
drwxr-xr-x  4 user user 4096 2011-07-05 09:52 .
drwxr-xr-x  3 user user 4096 2011-07-05 09:52 ..
d---------  2 user user 4096 2010-09-12 05:15 content
d--------- 25 user user 4096 2011-01-08 17:08 locale

user@PC:Desktop$ stat -c '%n %a' colt-dir/chrome/colt.jar\!/
colt-dir/chrome/colt.jar!/ 755
user@PC:Desktop$ stat -c '%n %a' colt-dir/chrome/colt.jar\!/content/
colt-dir/chrome/colt.jar!/content/ 0

user@PC:Desktop$ sudo chmod -R 755 colt-dir/chrome/colt.jar\!/ 

user@PC:Desktop$ ls -la colt-dir/chrome/colt.jar\!/
total 16
drwxr-xr-x  4 user user 4096 2011-07-05 09:52 .
drwxr-xr-x  3 user user 4096 2011-07-05 09:52 ..
drwxr-xr-x  2 user user 4096 2010-09-12 05:15 content
drwxr-xr-x 25 user user 4096 2011-01-08 17:08 locale

EDIT2: Actually, turns out other files may be lacking permissions too:

user@PC:Desktop$ ls -la colt-dir/
total 28
drwxr-xr-x 4 user user 4096 2011-07-05 09:52 .
drwxr-xr-x 5 user user 4096 2011-07-05 10:04 ..
drwxr-xr-x 3 user user 4096 2011-07-05 10:04 chrome
---------- 1 user user 1337 2011-06-23 00:05 chrome.manifest
drwxr-xr-x 3 user user 4096 2011-07-05 09:52 defaults
---------- 1 user user 1969 2011-06-23 00:05 install.rdf
---------- 1 user user 1275 2010-09-12 05:04 LICENSE.txt
user@PC:Desktop$ stat -c '%n %a' colt-dir/install.rdf 
colt-dir/install.rdf 0

... so best to chmod everything: sudo chmod -R 755 colt-dir/ before trying to make changes and pack (as in xpi-pack colt-dir colt-2.xpi)

Horseshoes answered 5/7, 2011 at 7:44 Comment(1)
Why not just use archive manager? It shows contents of the extensions.Aerophyte

© 2022 - 2024 — McMap. All rights reserved.