zShowPass

Shows password on mouseOver and focus, hides on mouseOut and blur

  1. // ==UserScript==
  2. // @name zShowPass
  3. // @namespace zLiquidMethod
  4. // @version 0.7
  5. // @description Shows password on mouseOver and focus, hides on mouseOut and blur
  6. // @include *
  7. // @grant none
  8. // @copyright Dustin Zappa 2014
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //////////////////////////////////////////////////////////////////////////////
  13. // functions
  14. //////////////////////////////////////////////////////////////////////////////
  15.  
  16. //////////////////////////////////////////////////////////////////////////////
  17. // Name: clearText
  18. // Abstract:
  19. //////////////////////////////////////////////////////////////////////////////
  20. function clearText() {
  21. this.type = "text";
  22. }
  23.  
  24.  
  25.  
  26. //////////////////////////////////////////////////////////////////////////////
  27. // Name: obscureText
  28. // Abstract:
  29. //////////////////////////////////////////////////////////////////////////////
  30. function obscureText() {
  31. this.type = "password";
  32. }
  33.  
  34.  
  35.  
  36. //////////////////////////////////////////////////////////////////////////////
  37. // Name: addEvents
  38. // Abstract:
  39. //////////////////////////////////////////////////////////////////////////////
  40. function addEvents() {
  41. var passFields = document.querySelectorAll("input[type='password']");
  42.  
  43. if (!passFields.length) {
  44. return;
  45. }
  46.  
  47. for (var i = 0; i < passFields.length; i++) {
  48. passFields[i].addEventListener("mouseover", clearText, false);
  49. passFields[i].addEventListener("focus", clearText, false);
  50. passFields[i].addEventListener("mouseout", obscureText, false);
  51. passFields[i].addEventListener("blur", obscureText, false);
  52. }
  53. }
  54.  
  55.  
  56. //////////////////////////////////////////////////////////////////////////////
  57. // events
  58. //////////////////////////////////////////////////////////////////////////////
  59.  
  60. // execute after load, just in case they generate password fields via javascript
  61. window.addEventListener("load", addEvents, false);
  62.  
  63.