Reputation: 49329
I am developing a firefox extension, i need to detect which operating system firefox is running on but i can't seem to find and info on how to do it?
Upvotes: 12
Views: 2001
Reputation: 6598
Firefox is moving to web-extension
API where you can use:
chrome.runtime.getPlatformInfo(info => console.log(info.os))
Possible os
values are: mac, win, android, cros, linux, openbsd
Documentation for getPlatformInfo
is here.
Warning: this doesn't work from content-script
, you will have to call your background-script
.
Upvotes: 0
Reputation: 53
For completeness, getting os string for the new addon-sdk:
const {Cc, Ci} = require("chrome");
const osString = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULRuntime).OS;
console.log(osString);
Upvotes: 0
Reputation: 49329
// 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;
Upvotes: 14