2009-09-13 8 views

Antwort

15

    // 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; 
+0

Für die Referenz: https://developer.mozilla.org/en/nsIXULRuntime – Nickolay

0

Zur Vollständigkeit os Zeichenfolge für die neue addon-sdk bekommen:

const {Cc, Ci} = require("chrome"); 
const osString = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULRuntime).OS; 
console.log(osString); 
0

Firefox bewegt zu web-extension API, wo Sie verwenden können:

chrome.runtime.getPlatformInfo(info => console.log(info.os)) 

Possible os values sind: mac, gewinnen, android, kreuz, linux, openbsd

Documentation for getPlatformInfo is here.

Warnung: dies nicht von content-script nicht funktioniert, müssen Sie Ihre background-script nennen.

Verwandte Themen