从Google Chrome扩展检测操作系统

mefy6pfw  于 2023-03-27  发布在  Go
关注(0)|答案(2)|浏览(141)

我正在开发一个Chrome扩展程序,我需要检测Chrome在哪个操作系统上运行,但我似乎找不到任何关于如何做到这一点的信息。请帮助。谢谢。

bvjxkvbb

bvjxkvbb1#

最近添加的,你可以在Chrome自己的API中使用getPlatformInfo方法:

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

f8rj6qna2#

您需要在window.navigator.appVersion中搜索OS名称和版本。
如果你只是想了解一个平台,请看这个答案。你可以通过搜索其他user agents来增强代码。
这里是a detailed list of Chrome user agent strings(点击链接查看它们的含义)。

相关问题