Created
May 1, 2017 20:39
-
-
Save michalkot/cfcc2be996279f833b25c215b2bebcb3 to your computer and use it in GitHub Desktop.
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
// Password generator bookmark. | |
// Fills in active text field OR all password fields if none is selected | |
// Run in chrome console, right click in bookmarks bar, select new page, paste in URL field | |
function passGen(n) { | |
let ar = new Uint32Array(n); | |
window.crypto.getRandomValues(ar); | |
ar = [...ar]; | |
const pass = ar.map(n => n.toString(32)).join('-'); | |
if (document.activeElement) document.activeElement.value = pass; | |
else [...document.querySelectorAll('input[type="password"]')].forEach(node => node.value = pass); | |
alert(pass); | |
} | |
copy(encodeURI(`javascript:(${passGen.toString()})(3)`)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment