xpmn / firefox-to-deepl

Firefox extension. Highlight text on a web page and send it to DeepL
https://addons.mozilla.org/en-US/firefox/addon/to-deepl/
MIT License
88 stars 8 forks source link

[WIP] Implement popup-translation #18

Closed kevinulrich closed 2 years ago

kevinulrich commented 2 years ago

Hi,

this PR implements a popup-based translation that will not lose page context as mentioned in #17. I have not implemented it directly in DOM as that would need further permissions that I personally would not feel comfortable giving to a translation extension. This thus uses the WebExtension Popup-API that will open a small window to the top right of your browser.

Unfortunately, since we need the DeepL API for this task users will need to get their own API key. Getting it however is free and very easy to attain. I have included instructions in the extension settings.

deepl2 deepl1

I have also added an option to choose between the existing way of opening a new tab and the new way of using the popup.

Overall, this has changed a lot and I didn't expect this to result in such a large refactor so please take your time in reviewing this. I've commented everything that's not immediately obvious so you can follow the changes I've made.

xpmn commented 2 years ago

Looks like too much for this small extension. Maybe I can create separated extension with this functional

kevinulrich commented 2 years ago

How about I remove the tab translation alltogether and we could make this PR the "api key only" variant while keeping the existing extension as it is?