Skip to content

Instantly share code, notes, and snippets.

@bfred-it bfred-it/README.md
Created Feb 9, 2017

Embed
What would you like to do?
Copy saved password bookmarklet
// Get non-empty, visible password fields
var fields = [...document.querySelectorAll('[type=password]')].filter(f => f.value && f.offsetParent);
var cpy = field => {
field.type = '';
field.select();
document.execCommand('copy');
field.type = 'password';
}
if (fields.length === 1) {
cpy(fields[0]);
} else {
document.body.addEventListener('click', e => {
cpy(e.target);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.