From 8240482e9d0b6da7a996bc581c9b5304ebcf22aa Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 24 Sep 2022 22:44:40 -0400 Subject: 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 --- ext/js/app/frontend.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'ext/js/app') 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)); + } } -- cgit v1.2.3