Skip to content

Instantly share code, notes, and snippets.

@leibovic
Created September 24, 2015 18:06
Show Gist options
  • Save leibovic/0c67200dd1a679d57578 to your computer and use it in GitHub Desktop.
Save leibovic/0c67200dd1a679d57578 to your computer and use it in GitHub Desktop.
Adds fake logins to yout Firefox login manager
/*
* This is a JavaScript Scratchpad.
*
* Enter some JavaScript, then Right Click or choose from the Execute Menu:
* 1. Run to evaluate the selected text (Cmd-R),
* 2. Inspect to bring up an Object Inspector on the result (Cmd-I), or,
* 3. Display to insert the result in a comment after the selection. (Cmd-L)
*/
function addFakeLogins(window) {
let LoginInfo = new Components.Constructor("@mozilla.org/login-manager/loginInfo;1", Ci.nsILoginInfo, "init");
function createLogin(hostURL, formURL, realm, username, password, modifications) {
let loginInfo = new LoginInfo(hostURL, formURL, realm, username, password, "u-field", "p-field");
loginInfo.QueryInterface(Ci.nsILoginMetaInfo);
if (modifications) {
for (let [name, value] of Iterator(modifications)) {
loginInfo[name] = value;
}
}
return loginInfo;
}
// Add some initial logins
let urls = [
"http://mozilla.org/",
"https://developer.mozilla.org/",
"https://bugzilla.mozilla.org/",
"https://mobile.twitter.com/",
"https://m.facebook.com/",
"https://accounts.google.com/",
"https://hire.jobvite.com/",
];
let oldTimeMs = Date.now() - (1000 * 60 * 60 * 24 * 100); // 100 days ago
for (let i = 0; i < 100; i++) {
let logins = [
createLogin(urls[0], null, "Mozilla", "kesyer.sozey@usual.org" + i, "he-killed-his-family-so-they-couldn't"),
createLogin(urls[1], urls[1], null, "kesyer.sozey@usual.org" + i, "he-killed-his-family-so-they-couldn't"),
createLogin(urls[2], urls[2], null, "kesyer.sozey@mozilla.com" + i, "Tr0ub4dour&3", { timePasswordChanged: oldTimeMs }),
createLogin(urls[3], urls[3], null, "kesyer.sozey@usual.org" + i, "been-on-twitter-since-2005"),
createLogin(urls[4], urls[4], null, "kesyer.sozey@usual.org" + i, "been-on-facebook-since-2004"),
createLogin(urls[5], urls[5], null, "kesyer.sozey@usual.org" + i, "password1"),
createLogin(urls[5], urls[5], null, "kesyer.sozey@gmail.com" + i, "aaaaa+123456", { timePasswordChanged: oldTimeMs }),
createLogin(urls[5], urls[5], null, "ksozey@me.com" + i, "correcthorsebatterystaple"),
createLogin(urls[6], urls[6], null, "kesyer.sozey@mozilla.com" + i, "neverforget3/13/1997"),
];
logins.forEach((login) => Services.logins.addLogin(login));
}
};
addFakeLogins(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment