Gaël Barbin
Gaël Barbin

Reputation: 3919

How to get the current version of Chrome from an extension?

I'm making a user-agent switcher for Chrome using the experimental API WebRequest, and I'd like to display the current user-agent used.

For that, I have to get the current version of Chrome, but I don't find anything about that in the doc and I can't access to the "chrome://version" page due to security considerations.

Do you have an idea to help me?

Upvotes: 1

Views: 2694

Answers (3)

HaNdTriX
HaNdTriX

Reputation: 29746

try

function getChromeVersion(){
  var match = window.navigator.userAgent.match(/Chrom(?:e|ium)\/([0-9\.]+)/);
  return match ? match[1] : null;
}

or use https://github.com/DamonOehlman/detect-browser for Multi-Browser Support.

Upvotes: 1

Jan
Jan

Reputation: 8141

How about

window.navigator.userAgent

on your backgroundpage?

Upvotes: 3

deviousdodo
deviousdodo

Reputation: 9172

You can always use the good old navigator object (navigator.userAgent is the exact property, but it contains many other informations), it's available to extensions.

Upvotes: 1

Related Questions