I'm porting a legacy Firefox extension to WebExtensions. I want to know at run time the version number of the extension itself. Right now I'm doing:
let extensionVersion = (function() {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType('application/json');
xhr.open('GET', browser.extension.getURL('manifest.json'), false);
xhr.send(null);
var manifest = JSON.parse(xhr.responseText);
return manifest.version;
})();
This dirty hack which relies on synchronous XHR. Is there a better way?