Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the windows user name using javascript in google chrome browser for 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.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.

like image 954
AMARESHWARAN Avatar asked Nov 14 '22 01:11

AMARESHWARAN


1 Answers

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.

like image 158
Livingston Samuel Avatar answered Dec 24 '22 13:12

Livingston Samuel