Password Revealer

Shows passwords on mouse hover or focus

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Password Revealer
// @namespace      http://userscripts.org/users/23652
// @description    Shows passwords on mouse hover or focus
// @include        http://*
// @include        https://*
// @include        file:///*
// @exclude        file:///*/perf.html*
// @copyright      JoeSimmons
// @version        1.0.51
// @license        GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// ==/UserScript==
(function() {




    var show_only_on_click = false; // only show passwords when you click on the field





    var handlers = [];

    function toText(e) {
        e = e.target;

        if (e.tagName === 'INPUT' && e.type === 'password') {
            // save the cursor position
            e.caretStart = e.selectionStart;
            e.caretEnd = e.selectionEnd;

            // switch it to text, but make it remember it was a password type
            e.type = 'text';
            e.oldType = 'password';

            // the selection range gets reset when we switch its type, so let's fix it
            e.setSelectionRange(e.caretStart, e.caretEnd);
        }
    }

    function toPassword(e) {
        e = e.target;

        if (e.tagName === 'INPUT' && e.oldType === 'password') {
            // save the cursor position
            e.caretStart = e.selectionStart;
            e.caretEnd = e.selectionEnd;

            // switch it to a password field
            e.type = 'password';

            // the selection range gets reset when we switch its type, so let's fix it
            e.setSelectionRange(e.caretStart, e.caretEnd);
            e.setSelectionRange(e.caretStart, e.caretEnd);

            // let's clean up our now-unused properties
            delete e.caretStart;
            delete e.caretEnd;
            delete e.oldType;
        }
    }

    function addHandlers() {
        var fields = document.querySelectorAll('input[type="password"]'), i, field;

        for (i = 0; field = fields[i]; i += 1) {
            if (handlers.indexOf(field) === -1) {
                field.addEventListener('focus', toText, false);
                field.addEventListener('blur', toPassword, false);
                handlers.push(field);
            }
        }
    }

    if (show_only_on_click === false) {
        window.addEventListener('mouseover', toText, false);
        window.addEventListener('mouseout', toPassword, false);
    } else {
        window.setInterval(addHandlers, 1000);
    }

}());