How to get extension version?

9,106 views
Skip to first unread message

Oleg Sokolov

unread,
Jun 16, 2011, 7:25:18 AM6/16/11
to Chromium-extensions
What method should I use to get my extension's version in the code?

Alchemy Code

unread,
Jun 16, 2011, 7:30:01 AM6/16/11
to Chromium-extensions
Hi,

you can try:

function getVersion() {
var version = 'NaN';
var xhr = new XMLHttpRequest();
xhr.open('GET', chrome.extension.getURL('manifest.json'), false);
xhr.send(null);
var manifest = JSON.parse(xhr.responseText);
return manifest.version;
}


but maybe there's an easier way to do that :)

PhistucK

unread,
Jun 16, 2011, 7:30:52 AM6/16/11
to Oleg Sokolov, Chromium-extensions
var manifest = new XMLHttpRequest();
manifest.open("get", "/manifest.json", true);
manifest.onreadystatechange = function (e) { if (manifest.readyState == 4) { alert(JSON.parse(manifest.responseText).version); } };
manifest.send({});

Should be good. ;)
PhistucK



On Thu, Jun 16, 2011 at 14:25, Oleg Sokolov <oleso...@gmail.com> wrote:
What method should I use to get my extension's version in the code?

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


GigAtom

unread,
Jun 16, 2011, 12:11:37 PM6/16/11
to Chromium-extensions
This should work:

var version = chrome.app.getDetails().version;

Scott Fujan

unread,
Jun 16, 2011, 12:44:17 PM6/16/11
to GigAtom, Chromium-extensions
I confirm that chrome.app.getDetails() works; even for an extension, and even in stable. However, I can't find any documentation on it, even at:


Am I missing something?


On Thu, Jun 16, 2011 at 11:11 AM, GigAtom <tgre...@bnet.at> wrote:
This should work:

var version = chrome.app.getDetails().version;

Michael Gundlach

unread,
Jun 16, 2011, 12:48:03 PM6/16/11
to Scott Fujan, GigAtom, Chromium-extensions
Weird; I just tried console.log(chrome.app.getDetails()) from a content script and got null, in Chrome Dev.

?

Scott Fujan

unread,
Jun 16, 2011, 1:00:12 PM6/16/11
to Michael Gundlach, GigAtom, Chromium-extensions
I tested in the background page

CqN on cr-48 devchannel 0.12.397.0

unread,
Jun 16, 2011, 1:10:36 PM6/16/11
to Chromium-extensions
On cr-48 stable, on an ext in the foreground, this

var version = chrome.app.getDetails().version;
alert(version) hangs the whole chrome, requiring power reboot!!

CqN

On Jun 16, 10:00 am, Scott Fujan <sc...@fujan.name> wrote:
> I tested in the background page
>
> On Thu, Jun 16, 2011 at 11:48 AM, Michael Gundlach <
>
>
>
>
>
>
>
> adblockforchr...@gmail.com> wrote:
> > Weird; I just tried console.log(chrome.app.getDetails()) from a content
> > script and got null, in Chrome Dev.
>
> > ?
>
> > On Thu, Jun 16, 2011 at 12:44 PM, Scott Fujan <sc...@fujan.name> wrote:
>
> >> I confirm that chrome.app.getDetails() works; even for an extension, and
> >> even in stable. However, I can't find any documentation on it, even at:
>
> >>http://code.google.com/chrome/extensions/trunk/api_index.html
>
> >> Am I missing something?
>
> >> On Thu, Jun 16, 2011 at 11:11 AM, GigAtom <tgrei...@bnet.at> wrote:
>
> >>> This should work:
>
> >>> var version = chrome.app.getDetails().version;
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups
> >>> "Chromium-extensions" group.
> >>> To post to this group, send email to chromium-extensi...@chromium.org.
> >>> To unsubscribe from this group, send email to
> >>> chromium-extensions+unsubscr...@chromium.org.
> >>> For more options, visit this group at
> >>>http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en
> >>> .
>
> >>  --
> >> You received this message because you are subscribed to the Google Groups
> >> "Chromium-extensions" group.
> >> To post to this group, send email to chromium-extensi...@chromium.org.
> >> To unsubscribe from this group, send email to
> >> chromium-extensions+unsubscr...@chromium.org.

GigAtom

unread,
Jun 16, 2011, 1:49:12 PM6/16/11
to Chromium-extensions
Did you report this problem? ...if not: http://new.crbug.com



On Jun 16, 7:10 pm, "CqN on cr-48 devchannel 0.12.397.0"

Kathy Walrath

unread,
Jun 17, 2011, 3:48:48 PM6/17/11
to PhistucK, Arne Roomann-Kurrik, GigAtom, Chromium-extensions
I'll look into this. Thanks for the email, PhistucK.

-k-

On Thu, Jun 16, 2011 at 11:26 AM, PhistucK <phis...@gmail.com> wrote:
Kathy, can the documentation be updates to include this information? this is much better than using XMLHttpRequest.

Also (or alternatively), can this function be introduced inside chrome.extension?
PhistucK

PhistucK

unread,
Jun 16, 2011, 2:26:04 PM6/16/11
to Kathy, Arne Roomann-Kurrik, GigAtom, Chromium-extensions
Kathy, can the documentation be updates to include this information? this is much better than using XMLHttpRequest.

Also (or alternatively), can this function be introduced inside chrome.extension?
PhistucK



On Thu, Jun 16, 2011 at 19:44, Scott Fujan <sc...@fujan.name> wrote:

Oleg Sokolov

unread,
Jun 18, 2011, 10:08:52 AM6/18/11
to Chromium-extensions
Thanks a lot for all answers

dhw

unread,
Jun 22, 2011, 10:40:05 AM6/22/11
to Chromium-extensions, Oleg Sokolov
If you have reproducible problems using
chrome.app.getDetails().version, first try the sample extension in:

http://code.google.com/p/chromium/issues/detail?id=86363#c4

and also try to provide the simplest possible extension that exhibits
this problem into the bug report. Thanks.

Michael Gundlach

unread,
Jun 16, 2011, 10:53:39 AM6/16/11
to PhistucK, Oleg Sokolov, Chromium-extensions
Oleg,

Be aware that PhistucK's version is asynchronous, so the version will only be available inside the onreadystatechange listener.  Alchemy Code's synchronous approach would probably work better for you.
Message has been deleted

dmitri...@postindustria.com

unread,
Feb 5, 2019, 8:00:58 AM2/5/19
to Chromium Extensions
chrome.app.getDetails() is deprecated now
you should use chrome.runtime.getManifest()
You can get current version of your application from chrome.runtime.getManifest().version
This code works for both web application and extension. Just be sure to call it from correct scope
Reply all
Reply to author
Forward
0 new messages