查看密码

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

当前为 2021-05-16 提交的版本,查看 最新版本

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