查看密码

😎双击显示密码, 5秒自动隐藏, 失去焦点自动隐藏

当前为 2021-10-24 提交的版本,查看 最新版本

  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.1
  6. // @author Finn
  7. // @name Show Password by double-click
  8. // @name:zh-CN 查看密码
  9. // @description 😎 Show password by double-click, and auto hide after 5 seconds, also hide when it blurs
  10. // @description:zh-CN 😎双击显示密码, 5秒自动隐藏, 失去焦点自动隐藏
  11. // @include *
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function () {
  16. 'use strict';
  17. document.addEventListener("dblclick", e => {
  18. const ev = e.target;
  19. if (ev.nodeName === "INPUT" && ev.getAttribute("type") === "password") {
  20. ev.setAttribute("type", "text");
  21. setTimeout(() => { ev.setAttribute("type", "password") }, 5000)
  22. ev.onblur= () => ev.setAttribute("type", "password")
  23. }
  24. })
  25. })();