Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// for use within chrome://passwordmgr/content/passwordManager.xul
// this is the title of the CSV data
var csv = `"hostname", "username", "password"`;
// the signons variable already exists when the document is loaded.
// looping through all entries, called e.
for (var e of signons) {
// JSON.stringify properly adds quotes, regardless of what characters the entries.
// so for every entry, take e.hostname, e.username, e.passwowrd and turn them into a quoted string
// end with a newline
csv += `${JSON.stringify(e.hostname)}, ${JSON.stringify(e.username)}, ${JSON.stringify(e.password)}\n`
}
// get a clipboard object
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper);
// and copy the csv data into the clipboard
clipboard.copyString(csv);
@mozfreddyb

This comment has been minimized.

Copy link
Owner Author

commented Apr 16, 2018

Without comments

var csv = `"hostname", "username", "password"`;
for (var e of signons) {
    csv += `${JSON.stringify(e.hostname)}, ${JSON.stringify(e.username)}, ${JSON.stringify(e.password)}\n`
}
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
                                   .getService(Components.interfaces.nsIClipboardHelper);
clipboard.copyString(csv);```
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.