Detect operating system from Google Chrome Extension

♀尐吖头ヾ 提交于 2019-12-01 03:18:10

Recently added, you can use the getPlatformInfo method in Chrome's own API:

chrome.runtime.getPlatformInfo(function(info) {
    // Display host OS in the console
    console.log(info.os);
});
serg

You would need to search for OS name and version inside window.navigator.appVersion.

If you just want to know a platform, see this answer. You can enhance the code by searching for other user agents.

Here is a detailed list of Chrome user agent strings (click on links to see what they mean).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!