Skip to content

Instantly share code, notes, and snippets.

@tayiorbeii
Last active November 9, 2022 22:00
Show Gist options
  • Save tayiorbeii/f825253120ffd74f9f1c597dcba6ed7d to your computer and use it in GitHub Desktop.
Save tayiorbeii/f825253120ffd74f9f1c597dcba6ed7d to your computer and use it in GitHub Desktop.
// Name: Embed clipboard url in Notion
// Description: Types /embed and pastes the clipboard url into Notion
import "@johnlindquist/kit"
await hide()
let link = await paste()
// parse the link from markdown string
let regex = /\[(.+)\]\((.+)\)/
// extract a url from a string
let urlRegex = /(https?:\/\/[^\s]+)/g
if (link.match(regex)?.length >= 1) {
link = link.match(regex)[1]
} else if (link.match(urlRegex)?.length >= 1) {
link = link.match(urlRegex)[0]
}
await keyboard.type("/emb")
await keyboard.pressKey(Key.Enter)
await wait(250)
await keyboard.type(link)
await keyboard.pressKey(Key.Enter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment