Created
November 5, 2022 20:58
-
-
Save jbranchaud/c046e538b225da591a606c3e55119a1f to your computer and use it in GitHub Desktop.
A ScriptKit script for putting a markdown link on your clipboard for the active Chrome tab
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
/** @type {import("@johnlindquist/kit")} */ | |
// Exclude: false | |
// Shortcut: control option v | |
const getChromeTabs = await npm("get-chrome-tabs") | |
// grab all tabs for all windows | |
const tabs = await getChromeTabs() | |
// grab the active tab for the front-most window | |
const activeTab = tabs.find(tab => tab.windowVisible && tab.active) | |
// in case the title is blank, use the URL as the title | |
const url = activeTab.url; | |
const titleIsPresent = activeTab.title && activeTab.title.trim !== ''; | |
const title = titleIsPresent ? activeTab.title : url; | |
// combine the title and URL into a markdown link | |
const markdownLink = `[${title}](${url})` | |
await copy(markdownLink) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment