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
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
Great idea! Never thought of that one and it is definitely possible. I’ll see what I can do. Welcome, @prashant.
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
Hi NIck,
Thanks for this.
I’ve installed it thanks to Popclip magic !
Hi NIck,
Thanks for this. This is really helpful !
good to hear!
I’ve just used it myself while writing a markdown document … pretty handy extension
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()
}
I’ve been looking for something like this. I’m trying to add to this snippet to take the copied URL and Title and paste it into a Drafts note with the UUID of 55A92996-0F69-41FE-82B8-96A87B22E7F0. This is what I tried but it didn’t work as an extension snippet, any ideas?
// #popclip
// name: Copy URL and Title to Drafts 5
// icon: text
// language: javascript
(function() {
function createDraftsUrlScheme(uuid, content) {
const encodedContent = encodeURIComponent(content);
const draftsUrl = `drafts5://x-callback-url/append?uuid=${uuid}&text=${encodedContent}`;
return draftsUrl;
}
const uuid = "55A92996-0F69-41FE-82B8-96A87B22E7F0";
const pageTitle = document.title;
const pageUrl = document.location.href;
const markdownLink = `[${pageTitle}](${pageUrl})`;
// Create Drafts 5 URL scheme to append the copied URL and title
const draftsUrlScheme = createDraftsUrlScheme(uuid, markdownLink);
// Copy the Markdown link to clipboard
const el = document.createElement('textarea');
el.value = markdownLink;
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
// Open the Drafts 5 URL scheme to append the URL and title
window.open(draftsUrlScheme, '_self');
})();
I’ve edited your snippet inline in your post to make the snippet format valid. I haven’t checked the code fully but at a glance it doesn’t look like it will do anything. Looks like it’s copied and pasted from some web code? document
for example, is not a global in PopClip’s JS environment.