Skip to content
This repository has been archived by the owner on Aug 16, 2022. It is now read-only.

chunliu/sttf-url-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archive this repo as the browsers (at least Edge and Chrome) has the functionality built-in them (e.g. Copy link to highlight).

Icon scroll-to-text-fragment url generator

build

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.

Get it from Chrome Web Store / Edge Add-ons

How to use it

how to use

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.

Note

  • 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. With v1.3, the extension helps to snap the selection to word.
  • Due to the algorithm of finding ranges in a document, the selection of the text snippet should avoid crossing multiple "block-level" elements. For example, if a selection is across a <h2> and a <div>, the browser may not be able to scroll to the text fragment accurately.