Last active
February 18, 2025 22:37
-
-
Save spaze/ab7a64862df2155d5f16dfef22d575b5 to your computer and use it in GitHub Desktop.
A bookmarklet code to reveal input field content and details
This file contains hidden or 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
// Add attributes as title tooltip | |
document.querySelectorAll('input').forEach(function(element) { | |
var attributes = []; | |
for (i = 0; i < element.attributes.length; i++){ | |
if (element.attributes[i].nodeName.toLowerCase() === 'title') { | |
continue; | |
} | |
if (element.attributes[i].nodeName.toLowerCase() === 'type' && typeof element.originalType !== 'undefined') { | |
var value = element.originalType; | |
} else { | |
var value = element.attributes[i].nodeValue; | |
} | |
attributes.push(element.attributes[i].nodeName + '=' + value); | |
} | |
attributes.sort((a, b) => a.localeCompare(b)); | |
if (typeof element.originalTitle === 'undefined') { | |
element.originalTitle = element.title; | |
} | |
element.title = element.originalTitle + "\n\nAttributes:\n" + attributes.join("\n"); | |
}); | |
// Reveal all hidden or masked fields | |
document.querySelectorAll('input[type=password],input[type=hidden]').forEach(function(element) { | |
element.originalType = element.type; | |
element.type = 'text'; | |
element.autocomplete = 'off'; | |
element.spellcheck = 'false'; | |
}); |
This file contains hidden or 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
javascript:(function()%7Bdocument.querySelectorAll(%22input%22).forEach(function(e)%7Bvar%20t%3D%5B%5D%3Bfor(i%3D0%3Bi%3Ce.attributes.length%3Bi%2B%2B)if(%22title%22!%3D%3De.attributes%5Bi%5D.nodeName.toLowerCase())%7Bif(%22type%22%3D%3D%3De.attributes%5Bi%5D.nodeName.toLowerCase()%26%26void%200!%3D%3De.originalType)var%20o%3De.originalType%3Belse%20var%20o%3De.attributes%5Bi%5D.nodeValue%3Bt.push(e.attributes%5Bi%5D.nodeName%2B%22%3D%22%2Bo)%7Dt.sort((e%2Ct)%3D%3Ee.localeCompare(t))%2Cvoid%200%3D%3D%3De.originalTitle%26%26(e.originalTitle%3De.title)%2Ce.title%3De.originalTitle%2B%22%5Cn%5CnAttributes%3A%5Cn%22%2Bt.join(%22%5Cn%22)%7D)%2Cdocument.querySelectorAll(%22input%5Btype%3Dpassword%5D%2Cinput%5Btype%3Dhidden%5D%22).forEach(function(e)%7Be.originalType%3De.type%2Ce.type%3D%22text%22%2Ce.autocomplete%3D%22off%22%2Ce.spellcheck%3D%22false%22%7D)%3B%7D)()%3B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment