Skip to content

Instantly share code, notes, and snippets.

@bsormagec
Created February 23, 2018 10:23
Show Gist options
  • Select an option

  • Save bsormagec/7ea10f72d9d7e32d561bb734a20189ad to your computer and use it in GitHub Desktop.

Select an option

Save bsormagec/7ea10f72d9d7e32d561bb734a20189ad to your computer and use it in GitHub Desktop.
Import Google Chrome Paswords to 1Password

This code snippet is for exporting passwords stored in Google Chrome for use in 1Password. It generates a 1Password compatiable CSV file.

NOTE: Your password are exported as plain text. Take proper precautions when storing the file and use a secure deletion tool.

To export your passwords follow these steps:

  • visit chrome://settings/passwords
  • Open the Chrome console (Mac: [Cmd] + [Option] + J / Windows or Linux: [Ctrl] + [Shift] + J`)
  • Paste the code above into the console
  • Enter your password when prompted so your keyring can be unlocked
  • Wait
  • Copy and paste the output to a file ending in .csv
  • Follow the 1Password CSV import guide
;(() => {
const asyncForEach = (array, done, iterator) => {
let i = 0
let next = err => {
if (err) {
done(err)
} else if (i >= array.length) {
done()
} else if (i < array.length) {
let item = array[i++]
setTimeout(function() {
iterator(item, i - 1, next)
}, 0)
}
}
next()
}
settingsUi = $$("settings-ui")
settingsPage = Polymer.dom(settingsUi[0].shadowRoot)
container = settingsPage.querySelector("#container")
settingsPasswordsAndForms = Polymer.dom(
Polymer.dom(
Polymer.dom(
settingsPage.querySelector("#main").shadowRoot
).querySelector("settings-basic-page").shadowRoot
).querySelector("settings-passwords-and-forms-page").shadowRoot
)
page = settingsPasswordsAndForms.querySelector("passwords-section")
.shadowRoot
passwordSection = Polymer.dom(
settingsPasswordsAndForms.querySelector("#pages")
).querySelector("#passwordSection")
list = Polymer.dom(page).querySelector("iron-list")
passwordItems = list.get("items")
asyncForEach(
passwordItems,
function () {
var txt = "";
for (i = 0; i < passwordItems.length; i++) {
var user = passwordItems[i].entry.loginPair.username;
var pw = passwordItems[i].password;
var url = passwordItems[i].entry.loginPair.urls.origin;
// 1pw csv login
txt += (url + ',' + url + ',' + user + ',' + pw + ',\n');
}
console.log(txt);
},
function(item, index, next) {
passwordSection.passwordManager_.getPlaintextPassword(
index,
function(item) {
passwordItems[index].password = item.plaintextPassword
next()
}.bind(passwordSection)
)
}
)
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment