Created
April 5, 2026 09:38
-
-
Save random-robbie/8989f3c6887953d653c6be309f09d421 to your computer and use it in GitHub Desktop.
Extra 30 days of bookmarks from yout twitter account to csv just copy in to console 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
| (async () => { | |
| const cutoff = new Date(Date.now() - 30 * 24 * 60 * 60 * 1000); | |
| const seen = new Map(); | |
| const sleep = ms => new Promise(r => setTimeout(r, ms)); | |
| function collectFromPage() { | |
| const articles = [...document.querySelectorAll('article')]; | |
| for (const article of articles) { | |
| const timeEl = article.querySelector('time'); | |
| const linkEl = article.querySelector('a[href*="/status/"]'); | |
| if (!timeEl || !linkEl) continue; | |
| const date = new Date(timeEl.dateTime); | |
| if (isNaN(date)) continue; | |
| const href = linkEl.href.split('?')[0]; | |
| if (date >= cutoff) { | |
| seen.set(href, { | |
| url: href, | |
| date: timeEl.dateTime, | |
| text: article.innerText.slice(0, 200).replace(/\s+/g, ' ') | |
| }); | |
| } | |
| } | |
| } | |
| let stagnant = 0; | |
| let lastCount = 0; | |
| for (let i = 0; i < 120; i++) { | |
| collectFromPage(); | |
| window.scrollTo(0, document.body.scrollHeight); | |
| await sleep(1500); | |
| collectFromPage(); | |
| if (seen.size === lastCount) stagnant++; | |
| else stagnant = 0; | |
| lastCount = seen.size; | |
| const oldestVisible = [...document.querySelectorAll('article time')] | |
| .map(t => new Date(t.dateTime)) | |
| .filter(d => !isNaN(d)) | |
| .sort((a, b) => a - b)[0]; | |
| if (oldestVisible && oldestVisible < cutoff && stagnant >= 3) break; | |
| } | |
| const rows = [...seen.values()].sort((a, b) => b.date.localeCompare(a.date)); | |
| const urls = rows.map(r => r.url).join('\n'); | |
| console.log(`Found ${rows.length} bookmarked tweet links from the last 30 days.`); | |
| console.table(rows); | |
| try { | |
| await navigator.clipboard.writeText(urls); | |
| console.log('Copied URLs to clipboard.'); | |
| } catch { | |
| console.log('Clipboard copy failed. URLs are in the console output.'); | |
| } | |
| // Optional CSV download | |
| const csv = [ | |
| ['date', 'url', 'text'], | |
| ...rows.map(r => [ | |
| `"${r.date.replace(/"/g, '""')}"`, | |
| `"${r.url.replace(/"/g, '""')}"`, | |
| `"${r.text.replace(/"/g, '""')}"` | |
| ]) | |
| ].map(row => row.join(',')).join('\n'); | |
| const blob = new Blob([csv], { type: 'text/csv' }); | |
| const a = document.createElement('a'); | |
| a.href = URL.createObjectURL(blob); | |
| a.download = 'twitter-bookmarks-last-30-days.csv'; | |
| a.click(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment