Greasy Fork

来自缓存

Greasy Fork is available in English.

星号密码框显示明文密码

密码框显示密码,支持懒加载、动态页面中的密码框,鼠标悬浮在密码框上时显示密码

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        星号密码框显示明文密码
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @grant       none
// @version     2.0
// @license     MIT
// @author      youngyy
// @description 密码框显示密码,支持懒加载、动态页面中的密码框,鼠标悬浮在密码框上时显示密码
// ==/UserScript==

(function() {
    'use strict';

    function bindPasswordEvents(input) {
        input.addEventListener('mouseenter', () => input.type = 'text');
        input.addEventListener('mouseleave', () => input.type = 'password');
    }

    const observer = new MutationObserver((mutations)=>{
      mutations.flatMap(e => [...e.addedNodes]).filter(node => node.nodeType === Node.ELEMENT_NODE).forEach(node => {
            if (node.tagName === 'INPUT' && node.type === 'password') {
                bindPasswordEvents(node);
            } else {
                node.querySelectorAll('input[type="password"]').forEach(bindPasswordEvents);
            }
        });
    });
    observer.observe(document, { childList: true, subtree: true });

    // 初始化现有密码输入框的事件绑定
    document.querySelectorAll('input[type="password"]').forEach(bindPasswordEvents);

})();