最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to get the windows user name using javascript in google chrome browser for google chrome extension - Stack Overflow

programmeradmin8浏览0评论

I have used the following code in javascript to get the windows user name in Firefox to create a firefox extension.

Components.classes["@mozilla/process/environment;1"].getservice(ponents.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.

I have used the following code in javascript to get the windows user name in Firefox to create a firefox extension.

Components.classes["@mozilla/process/environment;1"].getservice(ponents.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.

Share Improve this question edited Mar 17, 2011 at 5:50 Konerak 39.8k12 gold badges101 silver badges121 bronze badges asked Mar 17, 2011 at 5:44 AMARESHWARANAMARESHWARAN 511 gold badge1 silver badge2 bronze badges 3
  • 4 could you please use CAPITAL letters when needed and format your code – S L Commented Mar 17, 2011 at 5:47
  • 1 @Konerak Please tell me you used software for that, either way, thanks :) – alex Commented Mar 17, 2011 at 6:00
  • 1 @alex Notepad++ has a menu "TextFX", submenu "Characters" has options like "UPPER CASE", "lower case", "Proper Case", "Sentence case.", "iNVERT CASE" etc... very nice :) – Konerak Commented Mar 17, 2011 at 8:07
Add a ment  | 

1 Answer 1

Reset to default 1

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 promise 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.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论