1

Say, I want to develop an alternative spellcheck module to google docs. This means that I have to get corrections from my backend, and color the misspelled text's background, and do a small popup bubble when user hovers over it, where I'd display the correction. (please mind that spellcheck is not the actual goal of my project, but it does address my problems in a more simplified way)

What are my options? Any ideas how to do this?

Few possible solutions I came up with:

Chrome extension vs Apps script

Chrome extension

  • pros: user has to grant permissions once, can freely traverse and append anything to dom via content script
  • cons: is a "hacky" way, if google changes classnames or js source, it would stop working, and also, reverse engineering google docs's editor engine is impossible

Apps script

  • pros: supported by google: if it works, I dont need to be afraid of docs updates
  • cons: it seems to me that I can't just fiddle with the dom (because of Caja compiler), has very limited support (if any) for custom highlighting or hover functionality.

As I see it, neither of these are perfect solutions for this project. What do you think? Any suggestions are very welcomed.

Mihaly KR
  • 2,363
  • 2
  • 19
  • 20

2 Answers2

1

I know this is an old question, but I have recently gotten into the same problem, and believe I have a solution. So for future Googler's I will post my answer here.

My solution was to create a Chrome Extension and understand how the Google Docs DOM's are structures to interact with it.

You can find my code to work with the Google Doc DOM's here

Mr. JWolf
  • 1,375
  • 2
  • 14
  • 33
  • Great job and thanks for the answer! It may be an old ticket, but without any proper solution, so your repo will definitely save some prescious time for developers. How much would you say your implementation is likely to break due to future Google Docs Updates? Do you expect that you'll need to patch it frequently? – Mihaly KR Mar 14 '17 at 13:55
  • It is very hard to tell. It all depends on Google Docs. My gut feeling is, if Google decide to come with a big fanzy update to Google Docs, my solution will break and I will have to redo it. But otherwise I expect it to be stable. – Mr. JWolf Mar 15 '17 at 15:03
0

In Apps Script you can't "fiddle" with the DOM and you won't be able to implement hover functionality. Also, a lame Highlighting would involve changing the current document itself (which would go to revision history, undo queue, etc)

Therefore, your only altertive is the Chrome Extension. But I agree with you on the cons. It is a super hard task that could break at any minute without notice.

Henrique G. Abreu
  • 17,406
  • 3
  • 56
  • 65
  • There is an other option where I'd use both to make the thing work, but that would require the Apps Script and the Extension to communicate with each other. As I see it, that is simply not possible - or is it? – Mihaly KR Oct 21 '14 at 11:19
  • Hum... nice ideia. That might work. The is double installation requirement for the user and you'll have to reverse engineer the Add-on enabling mechanism (and comunication). Anyway, you'd also have to figure out Google Docs dom to implement your highlight and popup features. Apps Script will help you ver little with that. – Henrique G. Abreu Oct 21 '14 at 11:40
  • A simple GET should suffice I guess. One can GET the script url and run the code with /exec and add parameters `/exec?param=whatevs` The script should return a string then with the results. JSONP ajax is supposed to work. – Mihaly KR Oct 21 '14 at 14:26
  • I think you'll have to inform the oAuth2 token.. maybe not. I have never inspected how Google Docs calls an embedded Apps Script. – Henrique G. Abreu Oct 21 '14 at 16:24