Show/Hide Password when hovering over the input password
目前為
// ==UserScript==
// @name Show/Hide Password
// @version 1
// @description Show/Hide Password when hovering over the input password
// @icon https://cdn-icons-png.flaticon.com/512/312/312404.png
// @match *://*/*
// @grant none
// @license MIT
// @unwrap
// @namespace https://greasyfork.org/users/821661
// ==/UserScript==
(function () {
"use strict";
function showPassword(node) {
node.type = "text";
}
function hidePassword(node) {
node.type = "password";
}
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
mutation.addedNodes.forEach((node) => {
if (node.tagName === "INPUT" && node.type === "password") {
node.addEventListener("mouseover", () => {
showPassword(node);
});
node.addEventListener("focus", () => {
showPassword(node);
});
node.addEventListener("mouseout", () => {
hidePassword(node);
});
node.addEventListener("blur", () => {
hidePassword(node);
});
console.log("Input do tipo password adicionado:", node);
}
});
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
});
})();