双击显示密码明文 dbclick show password

双击密码输入框显示密码明文,5秒后或者点击其他地方恢复加密 Double-click the password input box to display the password plaintext, after 5 seconds, or click elsewhere to restore the encryption

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         双击显示密码明文 dbclick show password
// @namespace    https://172hk.top/
// @version      2024.03.13
// @description  双击密码输入框显示密码明文,5秒后或者点击其他地方恢复加密 Double-click the password input box to display the password plaintext, after 5 seconds, or click elsewhere to restore the encryption
// @author       朱颜科技
// @match        *://*/*
// @icon         https://hbimg.huabanimg.com/50c02765eb335ab6cafbb23cdcdd35dfb509698941e4-75uiH4_fw658
// @grant        none
// @license      MIT
// ==/UserScript==
 
(function () {
    'use strict';
 
    let timeout;
    document.addEventListener("dblclick", e => {
        const ev = e.target;
        if (ev.nodeName === "INPUT" && ev.getAttribute("type") === "password") {
            ev.setAttribute("type", "password_zykj");
            //失去焦点恢复加密
            ev.onblur = () => ev.setAttribute("type", "password");
            //清除之前的定时器
            clearTimeout(timeout);
            //定时5秒后恢复加密
            timeout = setTimeout(() => {
                ev.setAttribute("type", "password")
            }, 5000);
        }
    })
 
})();