Created
November 18, 2022 01:25
-
-
Save jbranchaud/9c5da9c30faefa00daf6bd4eb006f6c9 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 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")} */ | |
// Shortcut: control option v | |
const turnTitleAndUrlIntoMarkdownLink = ({title: _title, url}) => { | |
// in case the title is blank, use the URL as the title | |
const titleIsPresent = _title && _title.trim !== ''; | |
const title = titleIsPresent ? _title : url; | |
// combine the title and URL into a markdown link | |
const markdownLink = `[${title}](${url})` | |
return markdownLink | |
} | |
let jxa = await npm("@jxa/run") | |
let result = await jxa.run(() => { | |
let windows = Application("com.google.Chrome").windows() | |
let tab = windows[0].activeTab() | |
return { | |
url: tab.url(), | |
title: tab.title(), | |
} | |
}) | |
await copy(turnTitleAndUrlIntoMarkdownLink(result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment