Last active
April 12, 2021 20:13
-
-
Save caffeinewriter/179522b1429a595d48aade1be5070120 to your computer and use it in GitHub Desktop.
Password Toggle Bookmarklet
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 bodyData = document.body.dataset; | |
if (bodyData.bookmarkletPasswordToggle && bodyData.bookmarkletPasswordToggle === 'shown') { | |
const passInputs = document.querySelectorAll('input[data-password-shown=true]'); | |
passInputs.forEach(v => { | |
v.type = 'password'; | |
v.dataset.passwordShown = 'false'; | |
}); | |
bodyData.bookmarkletPasswordToggle = 'hidden'; | |
} else { | |
const passInputs = document.querySelectorAll('input[type=password]'); | |
passInputs.forEach(v => { | |
v.type = 'text'; | |
v.dataset.passwordShown = 'true'; | |
}); | |
bodyData.bookmarkletPasswordToggle = 'shown'; | |
} |
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
<h1>Toggle password visibility bookmarklet</h1> | |
<a href="javascript:(function()%7Bconst%20bodyData%20%3D%20document.body.dataset%3B%0Aif%20(bodyData.bookmarkletPasswordToggle%20%26%26%20bodyData.bookmarkletPasswordToggle%20%3D%3D%3D%20'shown')%20%7B%0A%20%20const%20passInputs%20%3D%20document.querySelectorAll('input%5Bdata-password-shown%3Dtrue%5D')%3B%0A%20%20passInputs.forEach(v%20%3D%3E%20%7B%0A%20%20%20%20v.type%20%3D%20'password'%3B%0A%20%20%20%20v.dataset.passwordShown%20%3D%20'false'%3B%0A%20%20%7D)%3B%0A%20%20bodyData.bookmarkletPasswordToggle%20%3D%20'hidden'%3B%0A%7D%20else%20%7B%0A%20%20const%20passInputs%20%3D%20document.querySelectorAll('input%5Btype%3Dpassword%5D')%3B%0A%20%20passInputs.forEach(v%20%3D%3E%20%7B%0A%20%20%20%20v.type%20%3D%20'text'%3B%0A%20%20%20%20v.dataset.passwordShown%20%3D%20'true'%3B%0A%20%20%7D)%3B%0A%20%20bodyData.bookmarkletPasswordToggle%20%3D%20'shown'%3B%0A%7D%7D)()%3B">toggle password visibility</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment