Unfortunately, Prism currently doesnt support FF addons (extensions) yet, but luckily will in the future. However, most addons should just work since both FF and Prism are based on the same subsystems. So...lets go ahead and fool Prism!
First, download the addon .XPI file. This file is really a .ZIP, so feel free to rename it or just open it with your favorate archive viewer. Inside you should find a file named install.rdf. This is where all the magic happens as it defines the target application for the addon. Open the file in a text editor and you should see something like this:
<em:targetapplication>The two lines that conserve us are the
<!-- Firefox -->
<description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minversion>3.0a1</em:minversion>
<em:maxversion>3.0.*</em:maxversion>
</description>
</em:targetapplication>
em:id
, and versions. Prism checks these values to make sure they match to what it expects. If it doesnt it tells you to go away! After digging around a bit I found the values that are needed for Prism:<em:targetapplication>You can have more than one
<!-- Prism -->
<description>
<em:id>prism@developer.mozilla.org</em:id>
<em:minversion>0.4</em:minversion>
<em:maxversion>1.0.0.*</em:maxversion>
</description>
</em:targetapplication>
targetApplication
tag, so just add the above right after the one for Firefox in your addon and you're all set!If you're not sure how to do the above, or are just lazy you can use the script below to convert the .XPI automatically! Unfortunately this will only work on linux so Windows and Mac people will have to stick to the instructions above.
#!/bin/bashJust save the below as
xpiFile=$1
tempDir=`mktemp -d`
tempZipFile=`mktemp`
tempRdfFile=`mktemp`
function cleanup {
# get rid of temporary working files
rm -rf $tempDir $tempZipFile $tempRdfFile > /dev/null
}
# make sure the XPI exists
if [ ! -e "$xpiFile" ]; then
echo "$xpiFile does not exist"
cleanup
exit
fi
# extract the files from the original package
unzip -d $tempDir $xpiFile > /dev/null
# make sure what you need is there
installRdfFile="$tempDir/install.rdf"
if grep -q "prism@developer.mozilla.org" $installRdfFile; then
echo "$xpiFile is already compatible with Prism, doing nothing"
cleanup
exit
fi
# replace stuff
sed "s_<em:targetApplication>_\
<em:targetApplication>\
<!-- Prism -->\
<Description>\
<em:id>prism@developer.mozilla.org</em:id>\
<em:minVersion>0.4</em:minVersion>\
<em:maxVersion>1.0.0.*</em:maxVersion>\
</Description>\
</em:targetApplication>\
&_" < $installRdfFile > $tempRdfFile
mv $tempRdfFile $installRdfFile
# rebuild the package
pushd $tempDir > /dev/null
rm $tempZipFile # i just needed the name, not the actual file
zip -r $tempZipFile * > /dev/null
popd > /dev/null
mv $tempZipFile $xpiFile
cleanup
mkPrismXpi.sh
, make it executable, and run it as such:./mkPrismXpi.sh myAddon.xpi
No comments:
Post a Comment