Show Password by double-click

😎 Show password by double-click, and auto hide after 5 seconds, also hide when it blurs

  1. // ==UserScript==
  2. // @namespace https://github.com/Germxu
  3. // @homepage https://github.com/Germxu/Scripts-for-TamperMonkey
  4. // @supportURL https://github.com/Germxu/Scripts-for-TamperMonkey/issues/new
  5. // @version 1.1.2
  6. // @author Finn
  7. // @license MIT
  8. // @name Show Password by double-click
  9. // @name:zh-CN 查看密码
  10. // @description 😎 Show password by double-click, and auto hide after 5 seconds, also hide when it blurs
  11. // @description:zh-CN 😎双击显示密码, 5秒自动隐藏, 失去焦点自动隐藏
  12. // @include *
  13. // @grant none
  14. // ==/UserScript==
  15.  
  16. (function () {
  17. 'use strict';
  18. document.addEventListener("dblclick", e => {
  19. const ev = e.target;
  20. if (ev.nodeName === "INPUT" && ev.getAttribute("type") === "password") {
  21. const v = ev.value
  22. ev.setAttribute("type", "text");
  23. ev.value = v
  24. setTimeout(() => { ev.setAttribute("type", "password") }, 5000)
  25. ev.onblur= () => ev.setAttribute("type", "password")
  26. }
  27. })
  28. })();