Chris Alexander
20th April, 2013
I’m (still) playing around with Chrome apps and extensions - and having fun doing it.
However there appears to be a lot of confusion around doing simple tasks. These are:
Various hacks involved using xhr to get the manifest file from the extension’s resources, and all kinds of brutal things.
Here I outline (finally) the definitive, clean, consistently supported way to do these things.
You could have any number of reasons for finding out exactly what your manifest file includes.
The definitive way:
chrome.runtime.getManifest()
This version is the one you set in the manifest file. Good for lots of reasons - checking you’re up to date, grabbing versioned external resources, the list goes on.
The definitive way:
chrome.runtime.getManifest().version
The ID for an extension is automatically generated by Chrome. You could need it for a variety of reasons, for example cross-extension messaging.
The definitive way is a bit trickier but well supported:
chrome.i18n.getMessage("@@extension_id")
There you go.