In different browsers, there are different ways to view saved passwords. If you don’t know how to do it in your password, and you are fortunate enough to find this page šŸ˜‰ , you could you simply do the following:

  1. Go to the page where your password is saved.
  2. Copy and paste the following into your address bar:
    javascript:(function(){for(var c=document.getElementsByTagName("INPUT"),a=c.length-1;a>=0;a--)(function(b){if(b.type.toUpperCase()=="PASSWORD"){var a=b.oncontextmenu;b.oncontextmenu=function(){try{clipboardData.setData("Text",b.value),alert("Your password has been copied to the clipboard.")}catch(c){alert("Your password is:\n"+b.value)}a&&a.apply(this,arguments);return!1}}})(c[a])})();
     
  3. Hit the enter key.
  4. Right click the password field to get your password.

For those of you who know JavaScript and want to know what the code originally looked like, it is as follows:

(function() {
  var arrInputs = document.getElementsByTagName("INPUT");
  for(var i = arrInputs.length - 1; i >= 0; i--) {
    (function(input) {
      if(input.type.toUpperCase() == "PASSWORD") {
        var oldOnContextMenu = input.oncontextmenu;
        input.oncontextmenu = function() {
          try {
            clipboardData.setData("Text", input.value);
            alert("Your password has been copied to the clipboard.");
          }
          catch(e) {
            alert("Your password is:\n" + input.value);
          }
          if(oldOnContextMenu)
            oldOnContextMenu.apply(this, arguments);
          return false;
        };
      }
    })(arrInputs[i]);
  }
})();

Basically, the code loops through all of the password fields and sets the oncontextmenu event so that it will either copy the password to the clipboard (IE only) or display the password in an alert. If oncontextmenu was previously set, this function will execute afterwards.

Categories: BlogJavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *