Skip to content

Instantly share code, notes, and snippets.

@lrecknagel
Created October 10, 2018 10:44
Show Gist options
  • Save lrecknagel/6a666304d82b6cb0e6d5042a7454c11d to your computer and use it in GitHub Desktop.
Save lrecknagel/6a666304d82b6cb0e6d5042a7454c11d to your computer and use it in GitHub Desktop.
Lumio IndexDB extraction
// DB_NAME via: ChromeDev Tools -> Application Tab -> Indexed DB
// should be something like: _pouch_bank_MD5_HASH
const DB_NAME = "YOUR_DB_NAME";
indexedDB.open(DB_NAME, DB_VERSION = 5).onsuccess = function (evt) {
const db = this.result;
const transaction = db.transaction("by-sequence", 'readonly');
const objectStore = transaction.objectStore("by-sequence");
const index = objectStore.index("_doc_id_rev");
const data = {candies: {}, collections: []};
index.openCursor().onsuccess = function(event) {
var cursor = event.target.result;
if (cursor) {
const { key } = cursor;
index.get(key).onsuccess = ({ target: { result } }) => {
const { ptype } = result;
if (ptype === 'CANDY') {
const { URL, title, _doc_id_rev } = result;
const id = _doc_id_rev.split('::')[0];
data.candies[id] = {url: URL, title};
} else if (ptype === 'STORYLINE') {
const { collectionCandies, title } = result;
data.collections.push({title, collectionCandies})
}
cursor.continue();
}
} else {
const collections = data.collections.map( ({ title, collectionCandies }) => {
const candies = collectionCandies.reduce( (acc, candyId) => {
const candy = data.candies[candyId];
if (candy) {
const { title, url } = candy;
return [...acc, { title, url }];
}
}, []);
return { title, candies };
});
console.log(JSON.stringify(collections));
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment