Anyone know how to extract the version that is inside the "manifest.json" dynamically at runtime?
Eg is it possible to do this?
alert("Version: "+extension.version);
This is a discussion on How do you display version inside manifest within the Plugins Development section, part of the Chrome Plugins category: Anyone know how to extract the version that is inside the "manifest.json" dynamically at runtime? Eg is it possible to ...
Anyone know how to extract the version that is inside the "manifest.json" dynamically at runtime?
Eg is it possible to do this?
alert("Version: "+extension.version);
Last edited by twinsen; 08-16-2009 at 10:53 AM.
I found a way. Post if you find a simpler way. Using this technique you can read data from any txt file.
Code:var req = new XMLHttpRequest(); req.open('GET', "manifest.json"); req.onreadystatechange = function() { if (req.readyState == 4) { var txt = req.responseText; // Note: In the extension, chrome reorders it with version last like this: // "version": "0.13" //} txt = txt.substring(txt.indexOf("version")); if (txt.indexOf(",")!=-1) { // If you put version earlier in the manifest this cuts everything // after the ",". This only applies if you open it directly and // not via the extension. txt = txt.substring(0,txt.indexOf(",")); } txt = txt.replace("version",""); txt = txt.replace(/\"/g,""); txt = txt.replace(/:/g,""); txt = txt.replace(/}/g,""); txt = txt.replace(/\s/g,""); g_version = parseFloat(txt); alert(g_version); } } req.send("");
a better way would be to evaluate the manifest ( it's Json ):
Code:var req = new XMLHttpRequest(); req.open('GET', "manifest.json"); req.onreadystatechange = function() { if (req.readyState == 4) { var manifest = eval('(' + req.responseText + ')' ); alert(manifest.version); } } req.send("");