-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
excuse me! I want Ask a question that is not related to this repository #1
Comments
Hello, apologies for late replies. I am busy with school lately. To begin with, I will advise you to type random characters in docs and inspect the DOM. You will find I will leave a few important class/id names here that you can just copy/paste directly. const GOOG_DEF = { // google docs definitions
IF_WINDOW_SELECT_PATH: ".docs-texteventtarget-iframe",
RECT_SELECT_PATH: ".kix-canvas-tile-selection > svg > rect",
CARET_SELECT_ID: "#kix-current-user-cursor-caret",
} I will leave a few hints here. Now, for example, you want to grab the selected text. One way you can do it is by using the way I mentioned in the original thread - i.e. by calculating the caret position - then calculating the index of the character based on the caret's screen coordinates - and then selecting text to the left or right in the code. The other way, the way LanguageTool uses, is by getting the screen coordinates of the beginning and the end of the selection they want (they calculate this by calculating width of characters with font css) and then dispatching a series of keyboard and mouse/mousedrag events to create a
For my project, all I needed was to select a couple characters to the left or right - which, again, I did using caret index instead of LanguageTool's way. If you might notice, the class name says Similarly, with the content on the page, you can access whatever is written inside the document, with all it's font styling in the DOM itself (
More on how to calculate this in the original thread - here. Now, about "trying to reverse engineer LanguageTool". You can access LanguageTool's source code where your browser stores the extension. Then just find the extension id from your browser and then searching it up in the file system. After you're done finding the source code for LanguageTool, you will have to beautify those files with one of those tools online, Because the files are of course minified, and it's a brain fuck. Although some functions retain their original names and you can use ChatGPT to rename the rest of the variables to get more context on how it works. Anyway, I hope you have fun working on this project and learn how it all functions (and how apps like docs fuck you up). Feel free to ask any more questions here, I can help by giving examples from my code/implementation, but expect delays since I am slow with replying 😄 |
Thank you very much for replying amidst your busy schedule. I am now able to obtain the text selected by the user and have also found the code for the browser extension. there are still have a few questions that confuses me:
Thank you again for your previous reply, and I wish you success in your studies!!! |
Hello friend, through AI and your help, I found the answer to my question above. I will post it in the comment below after I sort it out. |
I don't quite understand what you mean by the first question. But about the second question, doing iirc; the text annotation would be grouped page-by-page and then line-by-line. So with the caret position you can pretty much just get the active page and all the |
In the source code of LT, there is a line of code like this. When I commented it out, gdoc would not insert SVG elements into `kix-canvas-tile-selection`.
Here is a comparison chart:
According to some posts, one needs to apply to Google for a browser extension whitelist to have the privilege to implement such logic. I tried adding In the LT source code, I also found a |
Yep, adding And about adding the Also yeah, there's probably a lot to be had in LT's source code. I had a tight schedule when I worked on my project so I only looked for the bare minimum. By bare minimum, I mean I found simple workarounds that won't cost me much time. Maybe in future I work on making a docs library as a side project, lol. It shouldn't take me long this time now that I have most of the bullshit figured out. I noticed in the image you sent, line 145, it says You can dig around, maybe post in the original thread if you find something useful. |
irst of all, I'm sorry, I shouldn't ask this question here, but I didn't find a suitable way to send private messages, and I'm not familiar with whether GitHub has a way to send private messages!
In this issue, Amaimersion/google-docs-utils#10, you left a message about how you decompiled the language tool code, but then found how to get the selected text from Google Doc and insert text, but according to your message, I can only insert text, I want to know how to get the selected text.
Most importantly, I also want to know how you decompile the language tool code, which I think is a very important skill, but I don't know where to start learning
The text was updated successfully, but these errors were encountered: