Created
March 23, 2024 23:50
-
-
Save rwohleb/366c44ff728af526d46a53f86c7750dc to your computer and use it in GitHub Desktop.
Chrome Tabs Outliner extension DB dump
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Inspect the Tabs Outliner window. Run this code in the console. Copy the resulting HTML string. Save to a new HTML file. Done! | |
*/ | |
var connection = indexedDB.open('TabsOutlinerDB34', 2); | |
connection.onsuccess = (event) => { | |
const db = event.target.result; | |
const transaction = db.transaction(["current_session_snapshot"]); | |
const objectStore = transaction.objectStore("current_session_snapshot"); | |
const request = objectStore.get("currentSessionSnapshot"); | |
request.onerror = (event) => { | |
console.log(event); | |
}; | |
request.onsuccess = (event) => { | |
const linksDom = document.createElement("div"); | |
var targetElem, linkElem; | |
const tableData = request.result.data; | |
const linkData = {}; | |
for (i in tableData) { | |
const row = tableData[i]; | |
if (!row[0]) { | |
continue; | |
} | |
if (row[1] && row[2]) { | |
targetElem = getElemFromPath(linkData, row[2]); | |
if (row[1].data && row[1].data.url) { | |
linkElem = row[1].data; | |
linkElem.idxPath = row[2]; | |
if ('link' in targetElem) { | |
console.log("Duplicate link at " + row[2]); | |
} | |
targetElem.link = linkElem; | |
} | |
else if (row[1].data && row[1].type) { | |
targetElem[row[1].type] = row[1].data; | |
} | |
} | |
} | |
genLinkTree(linksDom, linkData); | |
console.log(linksDom.innerHTML); | |
}; | |
} | |
function getElemFromPath(data, idxPath) { | |
const idxPathCopy = [...idxPath]; | |
var elemPtr = data; | |
if (!idxPath.length) { | |
return; | |
} | |
do { | |
idx = idxPathCopy.shift() | |
if (!(idx in elemPtr)) { | |
elemPtr[idx] = {}; | |
} | |
elemPtr = elemPtr[idx]; | |
} while (idxPathCopy.length); | |
return elemPtr; | |
} | |
function genLinkTree(parentElem, data) { | |
var linkElem, childElem, titleElem, winDate; | |
if ('savedwin' in data) { | |
titleElem = document.createElement('h3'); | |
if (data.savedwin.crashDetectedDate) { | |
winDate = new Date(data.savedwin.crashDetectedDate); | |
titleElem.innerText = `Window (crashed ${winDate.toString()})`; | |
} | |
else { | |
titleElem.innerText = "Window"; | |
} | |
parentElem.appendChild(titleElem); | |
} | |
else if ('win' in data) { | |
titleElem = document.createElement('h3'); | |
titleElem.innerText = "Window"; | |
parentElem.appendChild(titleElem); | |
} | |
if ('link' in data) { | |
linkElem = document.createElement('a'); | |
linkElem.innerHTML = data.link.title; | |
linkElem.setAttribute('title', data.link.title); | |
linkElem.setAttribute('href', data.link.url); | |
parentElem.appendChild(linkElem); | |
} | |
const childKeys = Object.keys(data).filter((n) => !isNaN(parseFloat(n)) && isFinite(n)); | |
if (childKeys.length) { | |
const dlElem = document.createElement('dl'); | |
var dtElem; | |
for (childKey in childKeys) { | |
dtElem = document.createElement('dt'); | |
genLinkTree(dtElem, data[childKey]); | |
dlElem.appendChild(dtElem); | |
} | |
parentElem.appendChild(dlElem); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment