Hi! When I copy web source, I use ‘copy link to highlight’ feature frequently.
I’m using this snippet but this snippet just copy the website url simply.
How can I get selected text’s url? Which part should I edit?
#popclip
name: Copy text with url
icon: symbol:link.circle.fill
capture html: true
javascript: |
const url = popclip.context.browserUrl;
const text = popclip.input.text.trim();
const title = popclip.context.browserTitle || 'Untitled';
if (url && text) {
const highlightLink = url + '#:~:text=' + encodeURIComponent(text);
const formattedText = `${text} - [${title}](${url})`;
popclip.copyText(formattedText);
popclip.showSuccess();
} else {
popclip.showText('Unable to create link');
}
Thank you!