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

I am making a user-agent switch for Chrome using the experimental WebRequest API, and I would like to display the current user agent.

To do this, I need to get the current version of Chrome, but I donโ€™t know anything about this in the document, and I canโ€™t access the page "chrome: // version" due to security reasons.

Do you have an idea to help me?

+1
source share
3 answers

What about

window.navigator.userAgent 

on your original page?

+3
source

You can always use the good old navigator object ( navigator.userAgent is an exact property, but it contains a lot of other information), it is available for extensions.

+1
source

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 to support multiple browsers.

0
source

All Articles