ixrock / XTranslate

Easy translate text on web pages (chrome extension)
https://chrome.google.com/webstore/detail/xtranslate/gfgpkepllngchpmcippidfhmbhlljhoo
117 stars 28 forks source link

[BUG] Text-to-speech causes extension to crash in Opera #93

Closed owl-from-hogvarts closed 5 months ago

owl-from-hogvarts commented 5 months ago

What's wrong

Extension crashes when text is deselected. Issue comes from hidePopup method which unconditionally calls stopSpeaking. This in turn tries to access speechSynthesis object which is non-existent in Opera browser.

Stack Trace ![Stack trace](https://github.com/ixrock/XTranslate/assets/47751812/14dd132e-1664-40cf-9084-9d23afc5ad12) ``` Uncaught ReferenceError: speechSynthesis is not defined at stopSpeaking (user-script.js:27030:5) at Google.stopSpeaking (user-script.js:27216:9) at App.hidePopup (user-script.js:31701:63) at App.onMouseDown (user-script.js:31832:22) ```

Expected behavior

When text is deselected popup should hide without producing any errors

How to reproduce

  1. Install Opera browser
  2. Install the extension
  3. Launch any web-site
  4. Try to select text
  5. Wait for popup to appear
  6. Try clicking anywhere to hide popup
  7. See that popup does not hide
  8. Check browser's console to see error message

System information

XTranslate version: 3.3.2 Opera version: 110.0.5130.23 System: Arch Linux

I can provided more information on demand. I can't figure out right now what else can be useful.

owl-from-hogvarts commented 5 months ago

I propose a solution: check if text-to-speech is supported by browser and only then show try to work with it

ixrock commented 5 months ago

Opera not supported officially btw, lol. Free to open PR's for in separated branches / do own forks for Opera.

ixrock commented 5 months ago

This issue I believe is coming after this update: https://github.com/ixrock/XTranslate/commit/b121a83334874a15a452275b31caa7cec61942a2

ixrock commented 5 months ago

@owl-from-hogvarts I recommend to you also switch from opera to Brave / Chrome / Vivaldi. BTW I've been used opera since 6(or even 7) when it wasn't on chrome engine and stopped at some point, now it's more funny joke then a browser.