2

After Google Docs' update to canvas based rendering instead of HTML rendering, is it possible to force Google Docs' to render HTML from a chrome extension instead of a canvas? Somehow chrome extensions like Grammarly are able to do it but I'm not entirely sure how.

From my research though I think what allows them to do it through the _docs_force_html_by_ext variable, however I believe this is only for whitelisted extensions.

Is there some sort of alternative or a form I can fill out to get my extension whitelisted?

enter image description here

_docs_force_html_by_ext is undefined:enter image description here

_docs_force_html_by_ext is set through Grammarly:enter image description here

2
  • 1
    This variable should be set as window._docs_force_html_by_ext =true inside page context and your content script should run at document_start. Commented Nov 2, 2021 at 7:56
  • @wOxxOm - Do you know if setting this variable (to force HTML mode) works in Firefox extensions also? Commented Jan 26, 2022 at 20:49

2 Answers 2

7

There are two solutions to the problem: For older versions of Google Docs And for new versions.

Solution is for older versions of Google Docs

You need to add the GET-parameter ?mode=html to the URL.

For example if document URL is:
docs.google.com/document/exampleId/edit

Change URL to:
docs.google.com/document/d/exampleId/edit?mode=html

This will force Google Docs to use HTML-renderer.


Update March 4, 2022

Google changed the html render activation code. The html renderer is in the current code, and it works if you turn it on manually. I'm now looking into what new conditions need to be met to enable it automatically. I will report the results later.


Update March 9, 2022

The New solution

Once again, it proves that Google programmers are not as good as they are made out to be. So...

Now there are three ways to enable html rendering. At least I found three:

  1. Before the start of the Google Docs code:
    window._docs_force_html_by_ext == true ? 'html render' : 'canvas render'
  2. Before the start of the Google Docs code:
    (GET['mode']=='html' && window._docs_flag_initialData['kix-awcp'] == true) ? 'html' : 'canvas'
  3. Set the required parameters manually in the right place in the Google Doc code.

But, programmers at Google forgot that the window object also contains references to elements that have an id attribute set. For example:

HTML:
<span id="spanId"></id>
JS:
window['spanId'] == true;

That is, if we can add an id attribute to any element on the page, the value of which will be equal to _docs_force_html_by_ext, then we will automatically receive an identifier in the window object with !=false value. From which it follows that html rendering will turn on, since the conditions of method 1 are met. For example

<body id="_docs_force_html_by_ext ">

Hint 1: As far as I know, any browser plugin can run before the main code and add an id attribute to any element.

Hint 2: link element can have an id attribute to. I think you get the hint.

Sign up to request clarification or add additional context in comments.

11 Comments

I did reverse engineering of all Google docs.
My code explains what happens if certain conditions are met. For example I write: window._docs_force_html_by_ext == true ? 'html render' : 'canvas render' This code should be understood as - if before running the Google Docs script, the window._docs_force_html_by_ext identifier is set to a value that makes the expression window._docs_force_html_by_ext == true true, then html rendering will be enabled. That is, you need to set the value of the window._docs_force_html_by_ext identifier to any value before running the Google Docs code. I described other conditions in the same way.
Yes. I work about this
Any updates on this? @DemiMurych
I would be interested to know about this too.
|
1

Google is whitelisting some applications which can use a script forcing the document to a HTML Fallback version which reminds of the time before canvas or as an Annotated Canvas which makes it possible to make extension integrations with the SVG canvas.

You need to apply for whitelisting to access these features: https://docs.google.com/forms/d/e/1FAIpQLScFxMgvXlq2KMsp0UIM66pvThTF1hpojiXQTqyq9txW79OWag/viewform

8 Comments

While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
The message is small, so pasted it all and kept a link for the origin.
If you believe that another question has answers to this question, the correct thing to do is flag the question as a duplicate, not post the same answer.
Is the newest question then the one which should get flagged, or does this not matter?
The less popular one should point to the more popular one.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.