展示密码

直接查看密码

Versión del día 26/11/2021. Echa un vistazo a la versión más reciente.

// ==UserScript==
// @name         展示密码
// @namespace    arale
// @version      0.1
// @description  直接查看密码
// @author       Gj
// @match        *://*/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    const LocalEvnKey = 'show_password_env'
    const envKey = localStorage.getItem(LocalEvnKey) || 'hide'

    const findTarget = document.querySelectorAll('[type="password"]')
    function changeAttrByPwd(isShow) {
        findTarget.forEach(item => {
            item.setAttribute('type', isShow ? 'text' : 'password')
        })
    }
    changeAttrByPwd(envKey == 'show')

    const container = document.createElement('div')
    const labelDom = document.createElement('label')
    labelDom.innerText = '密码'
    labelDom.style.cssText = 'margin-right: 5px; font-size: 17px;color: #606266;'
    labelDom.setAttribute('for', 'show_password_check_box')
    container.appendChild(labelDom)

    const checkDom = document.createElement('input')
    checkDom.setAttribute('type', 'checkbox')
    checkDom.id = 'show_password_check_box'
    if (envKey == 'show') checkDom.setAttribute('checked', envKey)
    else checkDom.removeAttribute('checked')
    checkDom.onchange = function () {
        checkDom.setAttribute('checked', checkDom.checked)
        if (!checkDom.checked) checkDom.removeAttribute('checked')
        localStorage.setItem(LocalEvnKey, checkDom.checked ? 'show' : 'hide')
        changeAttrByPwd(checkDom.checked)
    }
    container.appendChild(checkDom)
    container.style.cssText = 'position: absolute;top: 10px;left: 70px;z-index: 9999;background-color: #fff;'

    if (findTarget.length > 0) document.body.appendChild(container)

})();
长期地址
遇到问题?请前往 GitHub 提 Issues。