How to link to selected text on a page in Chrome using bookmarklet

PHOTO EMBED

Tue Feb 14 2023 20:10:03 GMT+0000 (Coordinated Universal Time)

Saved by @mk000 #javascript #html

javascript:(function()%7Bconst selectedText %3D getSelection().toString()%3Bconst newUrl %3D new URL(location)%3BnewUrl.hash %3D %60%3A~%3Atext%3D%24%7BencodeURIComponent(selectedText)%7D%60%3Bwindow.open(newUrl)%7D)()
content_copyCOPY

https://www.howtogeek.com/677110/how-to-directly-link-to-text-within-a-web-page-in-chrome/