Skip to content

Commit

Permalink
more gdoc workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ken107 committed Mar 9, 2022
1 parent 9b648a6 commit e360fb3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
13 changes: 13 additions & 0 deletions js/content/google-doc-force-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

var brapi = (typeof chrome != 'undefined') ? chrome : (typeof browser != 'undefined' ? browser : {});

(function() {
var link = document.createElement('link');
link.id = "_docs_force_html_by_ext";
document.documentElement.appendChild(link);

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = brapi.runtime.getURL('js/page/google-doc-force-html.js');
document.documentElement.appendChild(script);
})()
15 changes: 15 additions & 0 deletions js/page/google-doc-force-html.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

if (!location.href.includes("mode=html")) {
if (location.href.includes("?")) location.href = location.href.replace("?", "?mode=html&");
else if (location.href.includes("#")) location.href = location.href.replace("#", "?mode=html#");
else location.href += "?mode=html";
}

if (!window._docs_force_html_by_ext) window._docs_force_html_by_ext = true
forceHtmlRenderingMode(100)

function forceHtmlRenderingMode(n) {
if (window._docs_flag_initialData) window._docs_flag_initialData['kix-awcp'] = true;
else if (n > 0) setTimeout(forceHtmlRenderingMode.bind(null, n-1), 0);
else console.warn("Could not set kix-awcp flag");
}
9 changes: 8 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "__MSG_extension_name__",
"short_name": "__MSG_extension_short_name__",
"description": "__MSG_extension_description__",
"version": "1.53.1",
"version": "1.54.0",
"default_locale": "en",

"browser_action": {
Expand Down Expand Up @@ -63,6 +63,13 @@
"page": "options.html",
"chrome_style": false
},
"content_scripts": [
{
"matches": ["https://docs.google.com/document/d/*"],
"js": ["js/content/google-doc-force-html.js"],
"run_at": "document_start"
}
],
"commands": {
"play": {
"suggested_key": {"default": "Alt+P"},
Expand Down

0 comments on commit e360fb3

Please sign in to comment.