Show Password on MouseOver

Show password when mouseover a password field

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name          Show Password on MouseOver
// @namespace     MickyFoley
// @description   Show password when mouseover a password field
// @version       1.1
// @author        MickyFoley
// @license       free
// @include       *
// @grant         none
// ==/UserScript==

(function() {
  function showPassword(event) {
    const target = event.target;
    if (target.matches('input[type="password"]')) {
      target.type = 'text';

      // Use MutationObserver to prevent interference
      const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
          if (mutation.attributeName === 'type' && target.type !== 'text') {
            target.type = 'text';
          }
        }
      });

      observer.observe(target, { attributes: true });

      const restoreType = () => {
        observer.disconnect();
        target.type = 'password';
        target.removeEventListener('mouseleave', restoreType);
      };

      target.addEventListener('mouseleave', restoreType, { once: true });
    }
  }

  document.addEventListener('mouseover', showPassword, true);
})();