Get all google chrome passwords without any third-party software

Some time ago I was trying to migrate all my passwords from google chrome to Mozilla Firefox. But there is way to download your passwords to a text file. Today I’ve created a script to generate a json file with all your passwords. If you find this usefull and want to contribute to my hapiness, buy me a coffe, I live in spain and here an expresso costs 1,5€ donate to my paypal account.

  1. First of all you have to type in the browser location input field following address: chrome://settings/passwords;
  2. Then you should open the debugger console by issuing ctrl+shift+j;
  3. Copy and Paste following script and press enter.
var getPasswords = function() {
    return new Promise((resolve, reject) => {

        var passwordList = document.querySelector('body > settings-ui').shadowRoot.querySelector('#main').shadowRoot.querySelector('settings-basic-page').shadowRoot.querySelector('#basicPage > settings-section.expanded > settings-autofill-page').shadowRoot.querySelector('#passwordSection').shadowRoot.querySelector('div:nth-child(15)');

        var passwordListItems = passwordList.querySelectorAll("div password-list-item");

        var passwords = [];

        passwordListItems.forEach((el, idx) => {

            el.shadowRoot.querySelector("#showPasswordButton").addEventListener("click", () => {

                setTimeout( () => {
                    passwords.push(
                        {
                            "website": el.shadowRoot.querySelector(".website-column").title,
                            "username": el.shadowRoot.querySelector("#username").value,
                            "password": el.shadowRoot.querySelector("#password").value
                        }
                    );

                    if (idx == passwordListItems.length - 1) {
                        resolve(passwords);
                    }

                }, 500);
            });

            el.shadowRoot.querySelector("#showPasswordButton").click()

        });
    });
}


function download(data, filename, type) {
    var file = new Blob([data], { type: type });
    var a = document.createElement("a"),
        url = URL.createObjectURL(file);
    a.href = url;
    a.download = filename;
    document.body.appendChild(a);
    a.click();
    setTimeout(function () {
        document.body.removeChild(a);
        window.URL.revokeObjectURL(url);
    }, 0);
}

getPasswords().then((passwords) => download(JSON.stringify(passwords), "passwords.json", "application/json"));