summaryrefslogtreecommitdiff
path: root/ext/js/app/frontend.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2022-09-24 22:44:40 -0400
committerGitHub <noreply@github.com>2022-09-24 22:44:40 -0400
commit8240482e9d0b6da7a996bc581c9b5304ebcf22aa (patch)
tree4d1621193b9990f6cb710a72f9b761aa2b471de6 /ext/js/app/frontend.js
parentda52caa15247f82377e5d914306de1713ed63cea (diff)
Google Docs accessibility update (#2235)
* Update Google Docs injection script * Create GoogleDocsUtil * Update Frontend.js to register GoogleDocsUtil's getRangeFromPoint handler * Update setting name and description * Add comment * Fix Firefox support
Diffstat (limited to 'ext/js/app/frontend.js')
-rw-r--r--ext/js/app/frontend.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js
index 4f704faf..3a262c65 100644
--- a/ext/js/app/frontend.js
+++ b/ext/js/app/frontend.js
@@ -17,6 +17,7 @@
/* global
* DocumentUtil
+ * GoogleDocsUtil
* TextScanner
* TextSourceRange
*/
@@ -164,6 +165,7 @@ class Frontend {
['Frontend.getPageInfo', {async: false, handler: this._onApiGetPageInfo.bind(this)}]
]);
+ this._prepareSiteSpecific();
this._updateContentScale();
this._signalFrontendReady();
}
@@ -770,4 +772,21 @@ class Frontend {
}
return null;
}
+
+ _prepareSiteSpecific() {
+ switch (location.hostname.toLowerCase()) {
+ case 'docs.google.com':
+ this._prepareGoogleDocs();
+ break;
+ }
+ }
+
+ async _prepareGoogleDocs() {
+ if (typeof GoogleDocsUtil !== 'undefined') { return; }
+ await yomichan.api.loadExtensionScripts([
+ '/js/accessibility/google-docs-util.js'
+ ]);
+ if (typeof GoogleDocsUtil === 'undefined') { return; }
+ DocumentUtil.registerGetRangeFromPointHandler(GoogleDocsUtil.getRangeFromPoint.bind(GoogleDocsUtil));
+ }
}