Search code examples
javascriptfirefox-addon-sdk

How to find the version of mozilla in add-on script in add-on sdk?


I want to determine the version of firefox on which my add-on will run. I know we can do that using jquery in content-script(page-mod) . But i want to know it before any content-script is attached to any page.

To clarify further... In my add-on script (main.js), I am making a request to my server,as a part of which i need to send the browser version and browser name ,to recieve some browser-version specific settings.

I can determine this using jQuery.browser.version in content-script after the very first page is loaded after installation of the add-on and communicate it to the add-on script using self.emit('event-name',payload) and store it using simple-storage. On subsequent requests i will have to check whether browser version has been updated.

What i wanted was a more direct way of doing it. I thought may be add-on sdk already provides it somewhere.


Solution

  • Found the answer using add-on-sdk's low-level api xul-app:

        var xul_app=require('xul-app');
        console.log(xul_app.version);
        console.log(xul_app.name);