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

后端 未结 2 1319
感情败类
感情败类 2021-01-11 10:05

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 f

相关标签:
2条回答
  • 2021-01-11 10:44

    from fastClick

    var chromeVersion=(/Chrome\/([0-9]+)/.exec(navigator.userAgent)||[,0])[1];
    
    0 讨论(0)
  • 2021-01-11 10:51

    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...
    }
    
    0 讨论(0)
提交回复
热议问题