Created
January 10, 2025 17:54
-
-
Save jbranchaud/ab69f372bff322ceb72ff49fea527be4 to your computer and use it in GitHub Desktop.
A ScriptKit script to grab URL and title for all Chrome tabs of current window
This file contains 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
/** @type {import("@johnlindquist/kit")} */ | |
// Name: Export all Chrome Tabs | |
// Description: Export all Chrome Tabs to Clipboard | |
let jxa = await npm("@jxa/run"); | |
let result = await jxa.run(() => { | |
// This was taking too long for windows with TONS of Chrome tabs. AppleScript | |
// was timing out. | |
// | |
// const extractMetadataForTab = (tab) => { | |
// const pageData = tab.execute({ | |
// javascript: `(function() { | |
// return { | |
// title: document.title, | |
// description: document.querySelector('meta[name="description"]')?.content, | |
// keywords: document.querySelector('meta[name="keywords"]')?.content, | |
// ogImage: document.querySelector('meta[property="og:image"]')?.content | |
// } | |
// })()`, | |
// }); | |
// | |
// return { | |
// url: tab.url(), | |
// ...pageData, | |
// }; | |
// }; | |
let windows = Application("com.google.Chrome").windows(); | |
let tabs = windows[0].tabs(); | |
return tabs.map((tab) => { | |
// return extractMetadataForTab(tab); | |
return { | |
url: tab.url(), | |
title: tab.title(), | |
}; | |
}); | |
}); | |
let prettyJson = JSON.stringify(result, null, 2); | |
// for debugging... | |
// await div( | |
// md(` | |
// ${prettyJson} | |
// `) | |
// ); | |
await copy(prettyJson); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment