itsecurityco / to-google-translate

Highlight text on a web page and send it to Google Translate
https://addons.mozilla.org/firefox/addon/to-google-translate/
386 stars 114 forks source link

TTS (Ctrl+Shift+2) link needs to be updated #104

Open ryanerwin opened 4 years ago

ryanerwin commented 4 years ago

to-google-translate seems to be using an older, no longer accessible version of a call to the Google Translate TTS engine.

When using Right Click > to Google Translate > Listen...

Or the keyboard shortcut CTRL + ALT + 2...

I keep on getting the following popup, and when I inspect the details, it seems Firefox is getting a 404 on the TTS audio file...

image

Example of current link with 404:

https://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&client=tw-ob&tl=en-US&q=sshpass%3A%20An%20Excellent%20Tool%20for%20Non-Interactive%20SSH%20Login%20%E2%80%93%20Never%20Use%20on%20Production%20Server&textlen=89

image

I believe the old link was basically:

http://translate.google.com/translate_tts?tl=en&q=Hello+world

And the new link is basically:

https://translate.google.com/translate_tts?ie=UTF-8&tl=en-US&client=tw-ob&q=Hello+world
itsecurityco commented 4 years ago

Hello @ryanerwin ,

But if you copy and paste the 404 URL directly in the browser you have a 200 response.

image

Looks like Google is blocking the requests if don't come from his domain. I need to investigate this.

Thanks for reporting.

ryanerwin commented 4 years ago

Interestingly enough, in my case, only the new link works to get a 200... Even pasting the old link into a new window, I'm getting a 403 (forbidden)

old link is top window, new link is bottom window...

image

inspector showing 403 on old link

image

itsecurityco commented 4 years ago

I see, but the extension don't use the old link, the actual URI generated to use the TTS option is

https://translate.google.com/translate_tts?ie=UTF-8&total=1&idx=0&client=tw-ob&tl=en-US&q=Hello+World

You can find it here:

https://github.com/itsecurityco/to-google-translate/blob/master/src/config.js#L31

ryanerwin commented 4 years ago

I see, but the extension don't use the old link, the actual URI generated to use the TTS option is

That's odd... Doesn't seem like it should be possible to ever get the old link to pop up, because as you pointed out, that link isn't even in the code...

Is the TTS function working for you?

Unfortunately, I still can't get it to work. Yet using ImTranslator (way too much bloat for me) the TTS option does work.

Any other suggestions on how to get to the bottom of this?