Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the version of Chrome browser from my extension?

I know I can add the

minimum_chrome_version property to my manifest file to require at least this version of chrome

But what I am looking for is to allow installation of my extension on any chrome version but then from the background page or from my options page check the version of the chrome browser version and based on than either enable or disable some features of my extension that depend on certain minumim version.

Surprisingly I was not able to find a way to do this, even googling for this did not help.

Does anyone know how to check the version of client's chrome browser that my extension is running on?

like image 885
Dmitri Avatar asked Oct 10 '13 11:10

Dmitri


1 Answers

You can extract get the current Chrome version from the user agent string:

var chromeVersion = /Chrome\/([0-9.]+)/.exec(navigator.userAgent)[1];

When using this to "detect" features, keep in mind the availability of some features vary between channels. In particular, many new features are already available on beta channels, but not on the stable channel, even though releases on both channels have the same version string. Instead of using the version to disable features, you can detect the presence of the APIs, e.g.:

if (chrome.declarativeWebRequest) {
    // Use declarativeWebRequest API...
} else {
    // fall back to webRequest API...
}
like image 62
Rob W Avatar answered Sep 18 '22 18:09

Rob W