I am making an add-on using the Firefox SDK 1.14.
Every time I make a new version of the addon, I have to change the "version" value of the packaje.json
file.
In a HTML page inside my addon, called index.html
which I use with addon-page module, I'd like to show the addon version. The only way I know to show it, is to manually edit the file before I run cfx xpi
. And because I have a horrible memory, I always forget to change it...
Is there any automated way to, just before compile the .xpi file, update the file version in my index.html
page?
By the way, I'm using Ubuntu.
The addon version
is accessible via the self
module.
var {name, id, version} = require("sdk/self");
Then you can set the contentScriptOptions
property when attaching a content script to your html file.
var self=require("sdk/self");
var tabs=require("sdk/tabs");
tabs.open({
url: self.data.url("index.html"),
onReady: function(tab){
var pageWorker=tab.attach({
contentScriptFile: self.data.url("contentscript.js"),
contentScriptOptions: {addonID: self.id}
});
}
});
From within the content script, access the contents of contentScriptOptions
(above) like so:
var id = self.options.addonID;