Skip to content

Commit e360fb3

Browse files
committed
more gdoc workarounds
1 parent 9b648a6 commit e360fb3

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
var brapi = (typeof chrome != 'undefined') ? chrome : (typeof browser != 'undefined' ? browser : {});
3+
4+
(function() {
5+
var link = document.createElement('link');
6+
link.id = "_docs_force_html_by_ext";
7+
document.documentElement.appendChild(link);
8+
9+
var script = document.createElement('script');
10+
script.type = 'text/javascript';
11+
script.src = brapi.runtime.getURL('js/page/google-doc-force-html.js');
12+
document.documentElement.appendChild(script);
13+
})()

js/page/google-doc-force-html.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
if (!location.href.includes("mode=html")) {
3+
if (location.href.includes("?")) location.href = location.href.replace("?", "?mode=html&");
4+
else if (location.href.includes("#")) location.href = location.href.replace("#", "?mode=html#");
5+
else location.href += "?mode=html";
6+
}
7+
8+
if (!window._docs_force_html_by_ext) window._docs_force_html_by_ext = true
9+
forceHtmlRenderingMode(100)
10+
11+
function forceHtmlRenderingMode(n) {
12+
if (window._docs_flag_initialData) window._docs_flag_initialData['kix-awcp'] = true;
13+
else if (n > 0) setTimeout(forceHtmlRenderingMode.bind(null, n-1), 0);
14+
else console.warn("Could not set kix-awcp flag");
15+
}

manifest.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "__MSG_extension_name__",
55
"short_name": "__MSG_extension_short_name__",
66
"description": "__MSG_extension_description__",
7-
"version": "1.53.1",
7+
"version": "1.54.0",
88
"default_locale": "en",
99

1010
"browser_action": {
@@ -63,6 +63,13 @@
6363
"page": "options.html",
6464
"chrome_style": false
6565
},
66+
"content_scripts": [
67+
{
68+
"matches": ["https://docs.google.com/document/d/*"],
69+
"js": ["js/content/google-doc-force-html.js"],
70+
"run_at": "document_start"
71+
}
72+
],
6673
"commands": {
6774
"play": {
6875
"suggested_key": {"default": "Alt+P"},

0 commit comments

Comments
 (0)