Guest User

Untitled

a guest
Oct 11th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. var userName = null;
  2. var passWord = null;
  3. var autoFillOnly = false;
  4. var getUrl = document.location.href;
  5.  
  6. chrome.extension.sendRequest( { eventName: "getSettings" },
  7. function(response) {
  8. userName = response.user;
  9. passWord = response.pass;
  10. autoFillOnly = response.autof;
  11. checkIfAutoUrl();
  12. }
  13. );
  14.  
  15. function checkIfAutoUrl() {
  16. if (getUrl.search("#autologin~") >= 1) { // If Url contains autologin parameters, continue, else start next function and end.
  17. var cutUrl = getUrl.split('~'); // Separates the parameters from Url.
  18. var parts = cutUrl[1].split('&'); // Separates the username and password from the parameters.
  19. userName = parts[0]; // userName is equal to 1st parameter.
  20. passWord = parts[1]; // passWord is equal to 2nd parameter.
  21. }
  22. if (userName != "" || passWord != "") { // Only autoLogin if the username or password isn't null. This is to prevent it from
  23. autoLogin(); // unecessarily trying to log you in with incorrect info.
  24. }
  25. }
  26.  
  27. function autoLogin() {
  28. var emailEle = document.getElementById("email"); // Set email box element as a variable.
  29. var passEle = document.getElementById("pw"); // Set password box element as a variable.
  30. emailEle.setAttribute("value", userName); // Fill out the email box with userName.
  31. passEle.setAttribute("value", passWord); // Fill out the password box with passWord.
  32. if (!autoFillOnly) { // Only click log-in if autoFillOnly is false.
  33. location.href = "javascript:void(login());"; // Press the login button.
  34. }
  35. }
Add Comment
Please, Sign In to add comment