如何在google chrome浏览器中使用javascript获取windows用户名以获得谷歌浏览器扩展 [英] How to get the windows user name using javascript in google chrome browser for google chrome extension
问题描述
我在JavaScript中使用了下面的代码来获取Firefox中的windows用户名,以创建一个Firefox扩展。
组件.classes [@ mozilla.org/process/environment;1\"].getservice(components.interfaces.nsienvironment).get('username');
现在我需要在JavaScript中为 Google Chrome 获取windows用户名以创建一个示例谷歌浏览器扩展。 提供一个扩展API来访问操作系统的信息,例如 Firefox
。
但是你可以写你的自己的NPAPI插件,从操作系统获取所需的信息;并且您的Chrome扩展程序可以通过JavaScript调用它。
请注意,NPAPI插件可以完全无限制地访问系统,因此攻击者可以利用任何漏洞危害用户系统。
参考: Chrome扩展程序NSAPI , MDC NPAPI参考资料
更新[02-Jan-2015]:正如更多详情。
I have used the following code in javascript to get the windows user name in Firefox to create a firefox extension.
Components.classes["@mozilla.org/process/environment;1"].getservice(components.interfaces.nsienvironment).get('username');
Now I need to get the windows user name in javascript for Google Chrome to create a sample google chrome extension.
Google Chrome
does not provide an Extension API to access the info from the Operating System, like Firefox
does.
But you can write your own NPAPI Plugin, which fetches the required info from the OS; and your Chrome extension can call it via JavaScript.
Please note that NPAPI plugin has full unrestricted access to the system, so any vulnerabilities can be used by an attacker to compromise the users system.
Reference: Chrome Extensions NSAPI, MDC NPAPI Reference
Update [02-Jan-2015]: As pointed out by levant pied, Chrome no longer supports NPAPI, but you can use PPAPI or NaCl modules to access the system. More details.
这篇关于如何在google chrome浏览器中使用javascript获取windows用户名以获得谷歌浏览器扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!