Skip to content

Instantly share code, notes, and snippets.

@teidesu
Created June 22, 2021 13:11
Show Gist options
  • Save teidesu/8198f9e29b800397f1dc5e5edf374b5c to your computer and use it in GitHub Desktop.
Save teidesu/8198f9e29b800397f1dc5e5edf374b5c to your computer and use it in GitHub Desktop.
Small script for exporting passwords from Firefox Lockwise to Chrome CSV
/*
Small script for exporting passwords from Firefox Lockwise to Chrome CSV
Usage:
1. Open passwords page (about:logins)
2. Open devtools (F12)
3. Paste the following script
4. Wait a few seconds, a download prompt will appear.
Tested with 70.0.1 (64-bit) (Linux x64)
(c) teidesu 2019. This script is licensed under GPLv3
*/
(function() {
let escape = s => JSON.stringify(s).replace(/\\"/g, '""')
let first = true
let download = (filename, text) => {
let el = document.createElement('a')
el.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
el.setAttribute('download', filename)
el.style.display = 'none'
document.body.appendChild(el)
el.click()
document.body.removeChild(el)
}
window.addEventListener("AboutLoginsChromeToContent", ev => {
let d = ev.detail
if (d.messageType === 'Setup' && first) {
first = false
let lines = ['name,url,username,password']
for (let login of d.value.logins) {
lines.push([login.title, login.formSubmitURL || login.origin || login.hostname, login.username, login.password].map(escape).join(','))
}
download('FirefoxLockwise.csv', lines.join('\n'))
}
})
document.dispatchEvent(new CustomEvent("AboutLoginsInit", { bubbles: true }))
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment