Copy from address bar as Markdown URL with title

Hi,

I’m new to POPCLIP , I want to copy a safari url in following format

[PopClip Forum](https://forum.popclip.app/latest?order=activity)

instead of what PopClip does now which is simply
https://forum.popclip.app/latest?order=activity

2 Likes

Great idea! Never thought of that one and it is definitely possible. I’ll see what I can do. Welcome, @prashant.

1 Like

Great to hear ! looking forward

doesn’t one of brett terpstra’s extensions do just that? but i am not sure if they work with the new popclip…

@noone - welcome to the forum! I don’t think any of Brett’s do exactly what @prashant is asking, but he does have a lot of cool extensions. I think they all ought to still work.

I put together the following extension snippet as a first approximation to the requirement here. In normal circumstances it behaves similarly to the regular to copy, except when copying from the address bar of a browser*, in which cases it copies as a markdown link.

# popclip extension to copy URL from address bar as markdown with title
name: Copy +MD Link
title: Copy
javascript: |
  if (popclip.input.text === popclip.context.browserUrl) {
    popclip.copyText(`[${popclip.context.browserTitle}](${popclip.input.text})`)
  } else {
    popclip.performCopy()
  }

(The above block is an extension snippet - select it to install the extension with PopClip)

*won’t work in Firefox because PopClip can’t detect the browser URL and title there

1 Like

Hi NIck,
Thanks for this.

I’ve installed it thanks to Popclip magic !

1 Like

Hi NIck,

Thanks for this. This is really helpful !

:smiley: :sparkles: good to hear!

I’ve just used it myself while writing a markdown document … pretty handy extension :star_struck:

Hi Nick,

Can I include some regex magic inside this ?

The URL I’m trying to capture as Markdown is

[What I want]
(hxxps://www.audible.com/pd/Armored-Audiobook/B09F16GN43?ref=a_ep_dec21-_c3_lProduct_1&pf_rd_p=5fcaaaf8-495c-44d7-aa04-6dd603dc6f84&pf_rd_r=F75E0CG0KZK1R437Q8S9)

But I would like to avoid everything after ? basically User identifier from amazon , from regex perspective , it simply

Find : (\?.*) Replace with (nothing)
so Above URL becomes
https://www.audible.com/pd/Armored-Audiobook/B09F16GN43

One possible approach:

# popclip
name: Copy Markdown Link
title: Copy
javascript: |
  let url = popclip.context.browserUrl
  if (popclip.input.text === url) {
    url = url.split('?')[0]
    popclip.copyText(`[${popclip.context.browserTitle}](${url})`)
  } else {
    popclip.performCopy()
  }