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)
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).
Thanks for that @rkaplan and everyone!
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.
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.
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.
Update 23 Oct 2025: Works in Arc now with PopClip 2025.9.1.
I am looking for a way to associate a link with a keyword of text. This is a feature available in some browsers, but not yet universal, although this is democratizing.
The easiest way is to add to the URL: #:~:text=, followed by the selected text.
I’ve tried different methods, but it doesn’t always work or it gets very complex. I guess this could be done easily?
Thank you for your help.
Bonjour,
Je recherche un moyen d’associer un lien à un surlignage de texte. Il s’agit d’une fonctionnalité disponible dans certains navigateurs, mais pas encore universel, bien que cela se démocratise.
Le plus simple consiste à ajouter à l’URL : #:~:text=, suivi du texte sélectionné.
J’ai essayé différentes méthodes, mais cela ne fonctionne pas toujours ou cela devient très complexe. J’imagine que cela pourrait être réalisé facilement ?
Okay, I understand.
That’s why when asking an AI, it resorted to AppleScript to retrieve the URL.
Here’s what it tells me; the comments are in French, but I imagine the code is understandable in all languages ^^.
#!/bin/bash
# --- 1️⃣ Récupération du texte sélectionné
text="$POPCLIP_TEXT"
# --- 2️⃣ Récupération de l'URL courante
url="$POPCLIP_BROWSER_URL"
# Si PopClip ne fournit pas l'URL, on tente via AppleScript
if [ -z "$url" ]; then
url=$(osascript <<'APPLESCRIPT'
tell application "System Events"
set frontApp to name of first process whose frontmost is true
end tell
if frontApp is "Safari" then
tell application "Safari" to return URL of front document
else if frontApp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if frontApp is "Brave Browser" then
tell application "Brave Browser" to return URL of active tab of front window
else if frontApp is "Microsoft Edge" then
tell application "Microsoft Edge" to return URL of active tab of front window
else if frontApp is "Arc" then
tell application "Arc" to return URL of active tab of front window
else if frontApp is "Firefox" then
tell application "Firefox" to activate
tell application "System Events"
keystroke "l" using {command down}
keystroke "c" using {command down}
delay 0.1
set theURL to the clipboard
end tell
return theURL
else
return ""
end if
APPLESCRIPT
)
fi
# --- 3️⃣ Encodage du texte pour l’URL
encoded_text=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$text'''))")
# --- 4️⃣ Construction du lien
if [ -z "$url" ]; then
echo "Impossible de récupérer l’URL de la page ❌" >&2
exit 1
fi
link="${url}#:~:text=${encoded_text}"
# --- 5️⃣ Copie dans le presse-papiers
echo -n "$link" | pbcopy
# --- 6️⃣ Affichage pour PopClip
echo "✅ Lien copié : $link"
PopClip already uses AppleScript similar to this internally to retrieve the URLs from browsers.
But the unsupported browsers don’t have an AppleScript interface, which is why they are unsupprted.
(PopClip doesn’t use the the ⌘L ⌘C method for Firefox or LibreWolf though – that is nasty! OK for a rough DIY script but having the URL bar getting selected all the time would not fly with users)
I don’t know anything about it, but of course I suspect that the code isn’t the best.
We need to find a solution for FF, that would be cool Then I have a plugin on FF that allows me to do it but I don’t know if it’s really a good thing …
Just installed this extension and it is great! Had no idea a browser could do this.
Don’t know if it’s possible, but it would be cool if there was a way to find additional occurrences of the selected text on the page. Kind of like Cmd-G for “search again”. I reckon that would be the responsibility of the browser, not of PopClip.