SHARE
TWEET

Chrome extension that posts user data

UlrichC Feb 21st, 2020 464 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var xhr = new XMLHttpRequest();
  2.  
  3. //just setting these do a default value for now.
  4. var ExtensionLoadTimeUnix = "Unavailable"
  5. var IPAddresses = "Unavailable"
  6. var AssetTag = "Unavailable"
  7. var SN = "Unavailable"
  8. var LoggedInUsers = "Unavailable"
  9. var ExtensionLoadTime = "Unavailable"
  10.  
  11.  
  12. //Acquire date and time in human readable format
  13. var ExtensionLoadTime = new Date();
  14. //Acquire date and time in Unix format.
  15. var ExtensionLoadTime_Unix = (new Date()).getTime()
  16. //Acquire date and time in ISO format.
  17. var ExtensionLoadTime_ISO = ExtensionLoadTime.toISOString()
  18.  
  19. //callback function to be ran after the nested functions run all of the Chrome API calls.
  20. function postData()
  21. {
  22.     xhr.open("POST", "http://servername:8080/", true);
  23.     xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  24.     xhr.send("SerialNumber="+SN+"&LoggedInUsers="+LoggedInUsers+"&AssetTag="+AssetTag+"&IPAddresses="+IPAddresses+"&ExtensionLoadTime="+ExtensionLoadTime+"&ExtensionLoadTime_Unix="+ExtensionLoadTime_Unix+"&ExtensionLoadTime_ISO="+ExtensionLoadTime_ISO);
  25.  
  26. }
  27.  
  28. //These set of nested functions each grab one of the variables from their respective API,
  29. //before finally performing a callback for postData().
  30.     //Acquire User Email
  31. chrome.identity.getProfileUserInfo(function(userInfo) {
  32.     LoggedInUsers = userInfo.email;
  33.         //Acquire Serial Number
  34.     chrome.enterprise.deviceAttributes.getDeviceSerialNumber(function(serialNumber) {
  35.         SN = serialNumber;
  36.          //Acquire Asset Tag
  37.         chrome.enterprise.deviceAttributes.getDeviceAssetId(function(assetId) {
  38.             AssetTag = assetId;
  39.             postData();
  40.         });
  41.     });
  42. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top