Last active
March 20, 2025 20:56
-
-
Save bkataru/b0407a259b40eaa89bb4baf404ffcc3b to your computer and use it in GitHub Desktop.
smol JS script to export OneTab links with additional useful metadata (tab count, creation timestamp, tab names), to use: go to OneTab page -> open DevTools (F12) -> open Console -> type "allow pasting" to disable XSS protection -> paste this script and press enter
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
| let tabGroups = document.getElementsByClassName('tabGroup'); | |
| const headerTemplatizer = (tabCount, timestamp) => ` | |
| --- | |
| ## ${tabCount} | |
| > ${timestamp} | |
| `; | |
| const tabTemplatizer = (textContent, href) => `[${textContent}](${href})`; | |
| function parseTabGroup(tabGroup) { | |
| let tabGroupString = ''; | |
| const [headerElem, tabListElem] = tabGroup.children; | |
| const [tabCount, timestamp] = headerElem.innerText.split('\n').slice(0, 2); | |
| tabGroupString += headerTemplatizer(tabCount, timestamp); | |
| for (let tab of tabListElem.children) { | |
| const {textContent, href} = tab.getElementsByTagName('a')[0]; | |
| tabGroupString += tabTemplatizer(textContent, href) + '\n' | |
| } | |
| return tabGroupString; | |
| } | |
| let compiled = ''; | |
| for(let tg of tabGroups) { | |
| const tgs = parseTabGroup(tg); | |
| compiled += tgs; | |
| } | |
| console.log(compiled); | |
| copy(compiled); | |
| console.log("copied tab groups to clipboard ✅"); | |
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
| // functional version (cuz we like purity, immutability, composition, currying, and allat) | |
| let tabGroups = document.getElementsByClassName('tabGroup'); | |
| const headerTemplatizer = (tabCount, timestamp) => ` | |
| --- | |
| ## ${tabCount} | |
| > ${timestamp} | |
| `; | |
| const tabTemplatizer = (textContent, href) => `[${textContent}](${href})`; | |
| const compiled = [...document.getElementsByClassName('tabGroup')].reduce((compiledAcc, tabGroup) => { | |
| const [headerElem, tabListElem] = tabGroup.children; | |
| const [tabCount, timestamp] = headerElem.innerText.split('\n').slice(0, 2); | |
| let tabGroupString = [...tabListElem.children].reduce((tabGroupStringAcc, tab) => { | |
| const {textContent, href} = tab.getElementsByTagName('a')[0]; | |
| return tabGroupStringAcc + tabTemplatizer(textContent, href) + '\n'; | |
| }, headerTemplatizer(tabCount, timestamp)); | |
| return compiledAcc + tabGroupString; | |
| }, ''); | |
| console.log(compiled); | |
| copy(compiled); | |
| console.log("copied tab groups to clipboard ✅"); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment