FooSoft / yomichan

Japanese pop-up dictionary extension for Chrome and Firefox.
https://foosoft.net/projects/yomichan
Other
1.05k stars 203 forks source link

Google Docs accessibility update #2235

Closed toasted-nutbread closed 1 year ago

toasted-nutbread commented 1 year ago

This change updates the implementation of the Google Docs accessibility scripts and restores some support for scanning on Google Docs pages. It currently lacks the ability to select text, since there is no real text, but it otherwise functions similar to how scanning input elements works: by creating a temporary "imposter" element and then scanning it.

Google exposes some structural text information in a hidden <svg> element if window._docs_annotate_canvas_by_ext is assigned to a whitelisted extension ID. This change registers an extension to DocumentUtil which will handle the scanning on Google Docs webpages.

The extension ID whitelist can be found by viewing the source of the main Google Docs script and searching for an ID which is known to be on the list, at least at the time of writing this. There is a big array of extension IDs, and Yomichan's ID ogmnaimimemjmbakcfefmnahgdfhfami is on that list, which is nice. (Maybe filling out that form mentioned in this comment actually did something!)

This implementation is still subject to the whims of Google's changes, which are unpredictable and undocumented.

Resolves #2231. Related: #2093, https://github.com/FooSoft/yomichan/issues/305#issuecomment-1249550618.

gadicc commented 1 year ago

Massive thanks for this. All my Japanese learning notes are in Google Docs... I've been getting by with 10ten (Rikaichamp) but have been missing Yomichan so much!