Skip to content

Instantly share code, notes, and snippets.

@mahmoudimus
Last active February 5, 2023 01:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mahmoudimus/53f526b37280c699515fb0d4a153b209 to your computer and use it in GitHub Desktop.
Save mahmoudimus/53f526b37280c699515fb0d4a153b209 to your computer and use it in GitHub Desktop.
Exports the history from Google Chrome's syncedTabs in chrome://history/syncedTabs
var tablistcontainer = (document.getElementById("history-app")
.shadowRoot.getElementById("synced-devices")
.shadowRoot.getElementById("synced-device-list"));
/* for sessionbuddy import */
var output = {tabs: []};
/* run through synced device cards *only* */
[].forEach.call(tablistcontainer.children, curNode => {
if (curNode.nodeName !== "HISTORY-SYNCED-DEVICE-CARD") {
return;
}
var historyitems = curNode.shadowRoot.getElementById("history-item-container");
var anchors = historyitems.querySelectorAll("div > a.website-link");
anchors.forEach((item) => output.tabs.push({
nx_title: item.getAttribute("title"),
url: item.getAttribute("href")
}));
})
copy(JSON.stringify(output));
/*
1. Go to chrome://history/syncedTabs
2. Open up the console
3. Copy & paste the script below into the console
4. Profit
*/
const history = document.querySelector("#history-app").shadowRoot;
const main = (history.querySelector("#main-container > iron-pages#content > history-synced-device-manager#synced-devices")
.root.querySelector("div#synced-device-list > history-synced-device-card"));
var anchors = root.querySelectorAll("div > a.website-title");
// anchors.forEach((item) => console.log(item.getAttribute("href")));
/* for sessionbuddy import */
var output = {tabs: []};
anchors.forEach((item) => output.tabs.push({Title: item.getAttribute("title"), URL: item.getAttribute("href")}));
copy(JSON.stringify(output)); // double JSON.stringify() if you need to escape into CSV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment