我正在开发一个firefox扩展,我需要检测哪个操作系统firefox正在运行,但我似乎无法找到和如何做到这一点的信息?
我正在开发一个firefox扩展,我需要检测哪个操作系统firefox正在运行,但我似乎无法找到和如何做到这一点的信息?
// Returns "WINNT" on Windows Vista, XP, 2000, and NT systems;
// "Linux" on GNU/Linux; and "Darwin" on Mac OS X.
var osString = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime).OS;
// Returns "WINNT" on Windows Vista, XP, 2000, and NT systems;
// "Linux" on GNU/Linux; and "Darwin" on Mac OS X.
var osString = Components.classes["@mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULRuntime).OS;
为了完整性,获取新的os字符串 插件-SDK:
const {Cc, Ci} = require("chrome");
const osString = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULRuntime).OS;
console.log(osString);
Firefox正在向 web-extension
您可以使用的API:
chrome.runtime.getPlatformInfo(info => console.log(info.os))
可能 os
值 是:mac,win,android,cros,linux,openbsd
警告: 这不起作用 content-script
,你将不得不打电话给你 background-script
。