A Chrome/Edge extension to generate the url with the scroll-to-text-fragment for the selected text. The extension will copy the url to the clipboard and open it in a new tab.
How to use it
Select a text snippet on the page, right click on the selection, and click
Open STTF Url. A url with the text fragment will be generated and copied to clipboard, and a new tab will be opened with the url.
How it works
The extension works in the following way.
- Following the suggestion of the text fragments spec, when the selection of the text snippet has less than 300 characters, the url will be generated with exact matching.
- If the text snippet has 300 or more characters, the url will be generated with range-based matching.
- For range-based matching, the first 5 words of the text snippet will be used as textStart, and the last 5 words will be used as textEnd.
- According to the spec, the selection of the text snippet must adhere to the word boundaries. In another words, the selection needs to start from the beginning of the first word and end at the ending of the last word of the text snippet. If the selection starts or ends at a character in a word, the browser would not be able to find the matching accurately.
- Due to the algorithm of finding ranges in a document, the selection of the text snippet should avoid crossing multiple blocks. For example, if a selection is across a
<div>, the browser may not be able to scroll to the text fragment accurately.