Copy link to text in page [Chrome specific at the moment]

There seems to be a chrome feature for copying a link to a specific excerpt of a web page: https://www.howtogeek.com/726473/how-to-create-a-link-to-selected-text-in-chrome/

The format of the link seems to be:

https://example.com/foo#:~:text=URL:%20encoded%20text

real example https://www.howtogeek.com/726473/how-to-create-a-link-to-selected-text-in-chrome/#:~:text=When%20the%20recipient%20clicks%20the%20link

The URL construction looks straightforward to guess but I wonder if there are any gotchas.

I wonder if there is a standard for this or is it or Chrome specific? Since it’s done with a fragment it’s likely harmless to any browsers that don’t support it.

A PopClip extension for this might be handy. (tweet)

1 Like

Extension snippet, seems to work!

#popclip
name: Copy Excerpt Link
icon: square E
javascript: popclip.copyText(popclip.context.browserUrl + '#:~:text=' + encodeURIComponent(popclip.input.text))

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

2 Likes

Didn’t understand the above, and this my fault. Can’t code. So, dumb question, if I use this safari what will I be able to do?

1 Like

This technique doesn’t seem to work in Safari on iOS (at least on my iPhone) — your example URL just opens the page at the top.

But combined with Choosy — or even just a chrome:// url handler, if that works out of the box — this would be amazing.

To try to explain: If you use Chrome, and you add something to end of any URL in Chrome, you can link not just to the top of the page, but to the place on the page where certain text appears. The part you add to the end of the URL is the text you’re linking to (but “encoded,” so spaces and other characters that don’t work on URLs are turned into %20 or something similar).

1 Like

The feature is unique to Chrome:

https://www.howtogeek.com/658842/how-to-use-google-chromes-new-deep-linking-feature/#:~:text=Chrome%2080%20makes%20that%20possible,Google%20Chrome%2080%20for%20now.

However there is a movement underway to develop a universal method to link among apps

3 Likes

Thanks for that @rkaplan and everyone! :sunglasses:
I hadn’t heard of this Chrome feature till yesterday when I saw a tweet asking for a PopClip extension to do the same thing. Glad I used the forum to flesh it out… I like how it can be a kind of interactive notebook.

1 Like

Hi Nick,

Thank you for sharing this extension snippet. Unfortunately, it seems that the popclip.context.browserUrl feature does not work with the ARC Browser. I tried using the provided extension snippet, and while it works perfectly with other supported browsers, it does not fetch the URL when using ARC Browser.

Is there any possibility to add support for ARC Browser in the future? It is my preferred browser for various reasons, and having PopClip fully functional with it would greatly enhance my workflow.

Thank you for your continuous efforts in developing and improving PopClip. It is a fantastic tool that has been incredibly helpful in my daily tasks.

1 Like

Unfortunately, unlike Chrome, Safari and some other browsers, Arc does not offer an AppleScript interface that allows PopClip to find out the URL of the current foreground tab. If Arc were to add a suitable interface then I could add support for it in PopClip.