Created
July 3, 2021 18:08
-
-
Save rawnly/030b1387419b72e5e9996f6221595f6b to your computer and use it in GitHub Desktop.
Sometimes it works, sometimes not. Better than nothing :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const genericButton = document.querySelector('[type="submit"]') | |
const password_input = document.querySelector('[type="password"]') | |
const button = document.createElement('button') | |
button.setAttribute('type', 'button') | |
button.innerText = 'Show Password' | |
button.style = "margin-top: 5px;" | |
if ( genericButton ) { | |
button.setAttribute('class', genericButton.getAttribute('class')) | |
} | |
button.onclick = (e) => { | |
e.preventDefault() | |
const el = document.getElementById(password_input.getAttribute('id')) | |
if ( el.getAttribute('type') === 'password' ) { | |
el.setAttribute('type', 'text') | |
button.innerText = 'Hide Password' | |
} else { | |
el.setAttribute('type', 'password') | |
button.innerText = 'Show Password' | |
} | |
} | |
genericButton.parentNode.appendChild(button) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment