Password revealer

This super simple browser extension reveals any password written to password input elements after typing 5 characters. It can be used to make a great prank on someone.

The code is really simple:

const fields = Array.from(document.querySelectorAll('input[type="password"]'));
fields.forEach((field) => {
    field.addEventListener('keydown', (e) => {
        if(e.target.value.length >= 5) {
            e.target.setAttribute('type', 'text');
            e.target.setAttribute('revealed', '');
        }
    });
});

First it queries for all HTML password input elements, then it assigns an event listener on keyboard input for each of these elements and lastly on each keypress it checks, if the input element contains more than 5 characters. If so, it changes the input type to plain text, which reveals the password.

As you can see, it doesn't do anything with the password, it doesn't send it to my server :)

Now everything that is left to do to make it a browser extension is to create a WebExtension manifest and add some fancy icon. It could look something like this:

{
  "manifest_version": 3,
  "name": "Password Revealer",
  "description": "This extension will reveal any password after typing 5 characters",
  "version": "1.0",
  "icons": {
    "16": "icon-16.png",
    "32": "icon-32.png",
    "48": "icon-48.png",
    "128": "icon-128.png"
  },
  "content_scripts": [
    {
      "js": [
        "reveal.js"
      ],
      "matches": [
        "<all_urls>"
      ]
    }
  ]
}

Now just add the extension to your browser (or more likely to browser of the person you want to prank).
In Chrome, go to chrome://extensions, in top right corner enable Developer mode, then click on Load unpacked and select the directory where you extracted the files. You may go to Details and enable all permissions for it.
For Firefox it is a bit different, you need to go to about:debugging, then open This Firefox, click on Load Temporary Add-on... and open either the zip archive you downloaded or if you extracted it, the manifest file. In Firefox you need to enable Access for all websites permission. To do that, go to about:addons, find Password Revealer, click on the three dots, go to Permissions tab and turn on the slider.

Download (revealer.zip, 10.1kB)

‹ Back