Show Password on MouseOver

Show password when mouseover a password field

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
})();