Toggle Passwords

Places a link "• T" at the right side of every password field. Clicking this link toggles the display of all passwords between •••• and text.(submitting a form will allways revert the fields to type=password, to make sure no auto-competion information is stored for these fields by your browser.)

当前为 2014-08-13 提交的版本,查看 最新版本

  1. // Toggle Passwords
  2. // version 1.0 BETA!
  3. // 2005-04-25
  4. // Copyright (c) 2009, jaron barends
  5. // Released under the Creative Commons GPL license
  6. // http://creativecommons.org/licenses/GPL/2.0/
  7. //
  8. // --------------------------------------------------------------------
  9. //
  10. // This is a Greasemonkey user script. To install it, you need
  11. // Greasemonkey 0.3 or later: http://greasemonkey.mozdev.org/
  12. // Then restart Firefox and revisit this script.
  13. // Under Tools, there will be a new menu item to "Install User Script".
  14. // Accept the default configuration and install.
  15. //
  16. // To uninstall, go to Tools/Manage User Scripts,
  17. // select "Toggle Passwords", and click Uninstall.
  18. //
  19. // --------------------------------------------------------------------
  20. //
  21. // ==UserScript==
  22. // @name Toggle Passwords
  23. // @namespace http://jaron.nl/
  24. // @description Places a link "• T" at the right side of every password field. Clicking this link toggles the display of all passwords between •••• and text.(submitting a form will allways revert the fields to type=password, to make sure no auto-competion information is stored for these fields by your browser.)
  25. // @version 1.0
  26. // @include *
  27. // @exclude
  28. // ==/UserScript==
  29.  
  30. window.pwToggler = {
  31. //create separate object to avoid conflicts
  32. pwFields: Array(),
  33. test: "aap",
  34. toggle: function() {
  35. var i;
  36. var pwFields = window.pwToggler.pwFields;
  37. var newType = (pwFields[0].type.toLowerCase() == "password") ? "text":"password";
  38. for (i=0; i<pwFields.length; i++) {
  39. pwFields[i].type = newType;
  40. }
  41. },
  42.  
  43. addToggleLink: function(afterEl) {
  44. var a = document.createElement("a");
  45. a.href = "#";
  46. a.title = "toggle all password masking";
  47. a.addEventListener("click", window.pwToggler.toggle, true);
  48. a.setAttribute("style", "margin-left:-20px;width:20px;font-size:10px; font-family:Georgia,'times new roman',serif;");
  49. a.innerHTML = "&#x25CF; T";
  50. window.pwToggler.insertAfter(a,afterEl);
  51. },
  52. insertAfter: function(newElement,targetElement) {
  53. var parent = targetElement.parentNode;
  54. if(parent.lastchild == targetElement) {
  55. parent.appendChild(newElement);
  56. } else {
  57. parent.insertBefore(newElement, targetElement.nextSibling);
  58. }
  59. },
  60. init: function() {
  61. var i;
  62. var pwFields = window.pwToggler.pwFields;
  63. //search all inputs and push into array
  64. var inputs = document.getElementsByTagName("input");
  65. for (i=0; i<inputs.length; i++) {
  66. var curr = inputs[i];
  67. if (curr.type.toLowerCase()=="password") {
  68. pwFields.push(curr);
  69. window.pwToggler.addToggleLink(curr);
  70. curr.form.addEventListener("submit",function(e) {
  71. if (window.pwToggler.pwFields[0].type == "text") {
  72. //change fields back to password to prevent browser storing value
  73. window.pwToggler.toggle();
  74. }
  75. },false);
  76. }
  77. }
  78. }
  79. }
  80. window.pwToggler.init();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址