Finding the currently logged in user from a Firefox extension

后端 未结 4 561
面向向阳花
面向向阳花 2020-12-16 05:55

I\'m writing a Firefox extension that needs to know what the username of the currently logged in user is in Windows, Mac, or Linux. So if I\'m logged into my machine as \"br

4条回答
  •  遥遥无期
    2020-12-16 06:10

    The flagged correct answer works fine. I use this in our extension on Firefox 38. I also use events so that the page can communicate with the extension and retrieve windows properties from the extension.

    getWindowsProperty: function(prop){ return Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment).get(prop); },

提交回复
热议问题