languagetool-org / languagetool-browser-addon

LanguageTool Firefox and Chrome Add-on (OUTDATED)
Other
131 stars 54 forks source link

Create "Javascript plugin" variant of existing browser add-on #220

Closed danielnaber closed 6 years ago

danielnaber commented 6 years ago

We have a browser add-on (Firefox, Chrome) that attaches itself to the textareas of each page to check them. Idea: use the same code so some Javascript snippet can be added to an HTML page so the add-on's functionality is in the page even when the user has not installed the add-on.

I image it can work like this: person who develops the HTML page adds a <script> tag with our code and maybe optionally calls some kind of init() method to specify e.g. the ids of the textarea to be enhanced by spell checking. That's all - the user gets the functionality of our add-on, the developer doesn't have to do anything else.

To get a better understanding, please install the add-on first and see how it works: it places a small icon in the lower right corner of every textarea. User can click it to get errors. In the dialog, user can select suggestions which are then used to replace the errors in the textarea. This is exactly what this Javascript plugin (is that a good name?) should do.

Notes:

nickchamel commented 6 years ago

@danielnaber as i far understood, it would be an ordinary js library that is connected to the page like everyone else. She will search for textareas in the DOM and add the necessary elements to them, as well as all the necessary api for checking words and everything else. Now we need to understand - all this code will need to be written from scratch? or not? What language is the addon for the browser written?

danielnaber commented 6 years ago

@neprev That's correct. Not much code needs to be written new, I hope. The code is all here at https://github.com/languagetool-org/languagetool-browser-addon/tree/master/webextension, mostly in sub directories bs, cs, and share. It's 100% Javascript, that's why I think you could do this.

danielnaber commented 6 years ago

Hi @neprev, any chance you can work on this soon?

danielnaber commented 6 years ago

@neprev Any update about this?

nickchamel commented 6 years ago

@danielnaber Hi, plan to do on Wednesday

danielnaber commented 6 years ago

Have you started already? Can you estimate how much time this might take? I'd like to know a (rough) estimate before we spend a lot of time here.

nickchamel commented 6 years ago

@danielnaber First of all, we can not just use the code that is in the extension. There are two options for the plugin:

  1. When the extension is installed and it works
  2. When there is no extension

In the first case, we need to configure the communication between the window and the extension. For example, do not initialize the connected library if an extension is installed and running. I think that there will not be much to write, but I can not say for sure. Today I will ask my colleagues about this.

In the second case (in addition to the code that is in the first), we need to initialize the library. But this will not be an extension, so it will not work with the WebExtensions API and its add-ons, so half of the methods will need to be fixed, the other half can be re-used (mostly manipulations with the DOM). Here the work can be divided into a couple of stages: 1 . Write the basic part: when initializing, go through the DOM, find the textareas, make the necessary edits, elements, hang events, configure the sending of the request to the server (some of it can be re-used, some not). A rough estimate for this stage is 10 hours

  1. Since this is not an extension, we can not take advantage, for example, of the internationalization API for extensions (https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Internationalization) So, we need to write a custom functional for language capabilities Plus, in the extension there are various settings, for which it is possible for the same reasons to write custom functionality. To appreciate this stage, I need a description of how works the extension with all its features, functionality, api, and so on.

Ready to work on the first stage. I'm waiting for your decision

danielnaber commented 6 years ago

Hi Nikita, thanks for the estimation. Someone else is currently making major changes to the add-on, so it makes sense to wait for that. Not sure yet how long it might take.