2009-09-13 7 views

答えて

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

参考:https://developer.mozilla.org/en/nsIXULRuntime – Nickolay

0

、新しいaddon-sdkのOSの文字列を取得:

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

Firefoxはあなたが使用することができますweb-extension APIに動いている:

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

Possible os valuesは以下のとおりです。マック、勝利、アンドロイド、クロス、linux、openbsd

Documentation for getPlatformInfo is here.

警告:これはcontent-scriptから動作しません、あなたのbackground-scriptを呼び出す必要があります。

関連する問題