Skip to content

Instantly share code, notes, and snippets.

@leibovic
Created September 24, 2015 18:06
Show Gist options
  • Select an option

  • Save leibovic/0c67200dd1a679d57578 to your computer and use it in GitHub Desktop.

Select an option

Save leibovic/0c67200dd1a679d57578 to your computer and use it in GitHub Desktop.

Revisions

  1. leibovic created this gist Sep 24, 2015.
    53 changes: 53 additions & 0 deletions add-logins.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    /*
    * 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", "[email protected]" + i, "he-killed-his-family-so-they-couldn't"),
    createLogin(urls[1], urls[1], null, "[email protected]" + i, "he-killed-his-family-so-they-couldn't"),
    createLogin(urls[2], urls[2], null, "[email protected]" + i, "Tr0ub4dour&3", { timePasswordChanged: oldTimeMs }),
    createLogin(urls[3], urls[3], null, "[email protected]" + i, "been-on-twitter-since-2005"),
    createLogin(urls[4], urls[4], null, "[email protected]" + i, "been-on-facebook-since-2004"),
    createLogin(urls[5], urls[5], null, "[email protected]" + i, "password1"),
    createLogin(urls[5], urls[5], null, "[email protected]" + i, "aaaaa+123456", { timePasswordChanged: oldTimeMs }),
    createLogin(urls[5], urls[5], null, "[email protected]" + i, "correcthorsebatterystaple"),
    createLogin(urls[6], urls[6], null, "[email protected]" + i, "neverforget3/13/1997"),
    ];
    logins.forEach((login) => Services.logins.addLogin(login));
    }
    };

    addFakeLogins(window);