Skip to content

Instantly share code, notes, and snippets.

@amoghs
Last active September 23, 2022 07:53
Show Gist options
  • Save amoghs/3a188b56f6ee6d5396d8c7438ad13781 to your computer and use it in GitHub Desktop.
Save amoghs/3a188b56f6ee6d5396d8c7438ad13781 to your computer and use it in GitHub Desktop.
A script to download your eesel data
;(function openTransaction(databaseVersion) {
let request = indexedDB.open('main', databaseVersion)
request.onsuccess = async (event) => {
const db = event.target.result
const objectStoreNameList = [
'commandList',
'commandHistoryEntryList',
'documentList',
'productList',
'upgradeList',
]
const transaction = db.transaction(objectStoreNameList, 'readonly')
const result = {}
objectStoreNameList.forEach((objectStoreName) => {
transaction.objectStore(objectStoreName).openCursor().onsuccess = (
event
) => {
const cursor = event.target.result
if (cursor) {
;(result[objectStoreName] = result[objectStoreName] || []).push(
cursor.value
)
cursor.continue()
}
}
})
transaction.oncomplete = () => {
const link = document.createElement('a')
link.href = `data:application/octet-stream;base64,${btoa(
unescape(encodeURIComponent(JSON.stringify(result, null, ' ')))
)}`
link.target = '_blank'
link.download = 'dump.json'
link.click()
}
}
request.onerror = async (event) => {
if (databaseVersion < 300) {
openTransaction(databaseVersion + 1)
}
}
})(126)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment