Show Password onFocus

By LouCypher Last update Oct 6, 2005 — Installed 4,220 times. Daily Installs: 1, 4, 0, 0, 0, 0, 2, 6, 0, 1, 4, 0, 2, 2, 3, 1, 1, 0, 0, 2, 0, 0, 1, 1, 5, 2, 1, 2, 1, 3, 0, 0
// ==UserScript==
// @name          Show Password onFocus
// @namespace     http://zoolcar9.lhukie.net/
// @include       *
// @description	  Show password when focus on password field
// ==/UserScript==
// Changelog:
// - 20051010: used XPath;

(function() {
  var inputs, input;
  inputs = document.evaluate(
    '//input[@type="password"]',
    document,
    null,
    XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
    null);
  if(!inputs.snapshotLength) return;
  for(var i = 0; i < inputs.snapshotLength; i++) {
    input = inputs.snapshotItem(i);
    input.addEventListener('focus', function(event) {
      this.type = 'text';
    }, false);
    input.addEventListener('blur', function(event) {
      this.type = 'password';
    }, false);
  }
})();