Closed mathewthe2 closed 1 year ago
Related issue https://github.com/lrorpilla/jidoujisho/issues/133
Hey @mathewthe2, thanks for pointing this out to me.
I've modified the JavaScript I inject accordingly with the reference you posted above here and it appears to work on Chrome in various font sizes.
Issue
Text selection is unreliable
Reason
Selection relies on caretRangeFromPoint and range.startOffset, which selects the next character when the cursor selects around 70% of the previous character.
https://github.com/birchill/10ten-ja-reader/blob/fbbbde5c429f1467a7b5a938e9d67597d7bd5ffa/src/content/get-text.ts#L248
Suggestion
Adjust position by getting the bounding box of the previous character and see if point is within that bounding box. If yes, use previous character.