jelmervdl / translatelocally-web-ext

TranslateLocally for the Browser is a web-extension that enables client side in-page translations for web browsers.
https://addons.mozilla.org/en-GB/firefox/addon/translatelocally-for-firefox/
Mozilla Public License 2.0
65 stars 3 forks source link

Manifest v3 compatibility #21

Closed jelmervdl closed 1 year ago

jelmervdl commented 2 years ago

Ultimately this should solve #10.

jelmervdl commented 2 years ago

The general problem was that it was impossible to load the WASMTranslationWorker inside the background-script context. This is now solved by loading it in the tab, in an iframe in the top-most frame. Similar to how the original firefox-translations addon does it. Translation requests from all frames in a tab are then proxied through the background-script to that one iframe.

Downside is that we now have 1 translator loaded per tab instead of one shared among all tabs, and that it does not survive page navigation. Performance is therefore worse than the manifest-v2 branches of this add-on. But it is similar to the Mozilla version of this add-on. So probably it is good enough…

jelmervdl commented 2 years ago

https://bugzilla.mozilla.org/show_bug.cgi?id=1687778 would be helpful, although I can probably shim it reasonably easy since in Firefox effectively the worker stays in memory, so just a local variable can do this work as long as I'm not trying to sync it between the popup and the background-script. (content-script should have no access to begin with according to the spec?)

jelmervdl commented 1 year ago

More documentation! https://blog.mozilla.org/addons/2022/10/31/begin-your-mv3-migration-by-implementing-new-features-today/

jelmervdl commented 1 year ago

I don't know what Google is doing but V3 is still a hot mess. It feels a lot like how Twitter killed their ecosystem when they turned off their API.

jelmervdl commented 1 year ago

Superseded by #73