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
1 Answer
Reset to default 1Google 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.