kuanyui / Furiganaize

A browser extension allowing the injection of phonetic annotations for Japanese text (furigana) on the fly.
https://addons.mozilla.org/en-US/firefox/addon/furiganaize/
MIT License
64 stars 3 forks source link

Missing support for live-updated HTML #5

Closed Zenahr closed 2 years ago

Zenahr commented 3 years ago

It would be nice if Furiganize worked on sites such as Twitch.tv where the DOM tree has to be traversed multiple times (for the chat box).

kuanyui commented 2 years ago

Please consider to make a PR. I have no interest to implement this because I don't need and I have no enough free time to make this for free.

kuanyui commented 2 years ago

This has been implemented in latest v0.6.0, need to be enabled manually in options.

If this helps you, please consider donation.

nonetrix commented 5 months ago

I think there might be a delay every time it tries to scan, this doesn't work well for subtitles. Could there be a feature added to customize this delay perhaps? If anyone feels like it, would help me a lot. Though might look into adding it myself though, if someone could point me to the code where this is done and where to add things to the UI it would help greatly. I think I have a powerful enough PC to parse it more without it slowing down much

kuanyui commented 5 months ago

I think there might be a delay every time it tries to scan, this doesn't work well for subtitles. Could there be a feature added to customize this delay perhaps? If anyone feels like it, would help me a lot. Though might look into adding it myself though, if someone could point me to the code where this is done and where to add things to the UI it would help greatly. I think I have a powerful enough PC to parse it more without it slowing down much

  1. I have no time to implement a feature I don't need, especially for free.
  2. There's already a debounce delay timer before parsing sentences in DOM. A rough mechanism is:
  3. MutationObserver found something changed, start debounce delay timer.
  4. Waiting for debounce delay timer timeout, if some other thing changed, restart this timer
  5. When debounce timeout, pass all changed parts from tab -> background -> WebWorker (separated thread against background script) to analyze Japanese sentences (this process is asynchronized)
  6. When the WebWorker finished, Worker will notify and send the furigana to the original tab.
  7. Have you done a profiling and ensure where is the performance bottleneck? The most resource consuming part is Japanese sentences' analysis but it has been already done in a separated process / thread and should not slow down your computer, unless it's really too too slow.