diff options
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/app/frontend.js | 16 | ||||
-rw-r--r-- | ext/js/background/backend.js | 12 | ||||
-rw-r--r-- | ext/js/comm/api.js | 8 |
3 files changed, 2 insertions, 34 deletions
diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index c8b63813..b68b55f3 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -16,7 +16,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import {GoogleDocsUtil} from '../accessibility/google-docs-util.js'; import {EventListenerCollection, invokeMessageHandler, log, promiseAnimationFrame} from '../core.js'; import {DocumentUtil} from '../dom/document-util.js'; import {TextSourceElement} from '../dom/text-source-element.js'; @@ -964,7 +963,7 @@ export class Frontend { _prepareSiteSpecific() { switch (location.hostname.toLowerCase()) { case 'docs.google.com': - this._prepareGoogleDocsWrapper(); + this._prepareGoogleDocs(); break; } } @@ -972,19 +971,8 @@ export class Frontend { /** * @returns {Promise<void>} */ - async _prepareGoogleDocsWrapper() { - if (typeof GoogleDocsUtil !== 'undefined') { return; } - await yomitan.api.loadExtensionScripts([ - '/js/accessibility/google-docs-util.js' - ]); - this._prepareGoogleDocs(); - } - - /** - * @returns {Promise<void>} - */ async _prepareGoogleDocs() { - if (typeof GoogleDocsUtil === 'undefined') { return; } + const {GoogleDocsUtil} = await import('../accessibility/google-docs-util.js'); DocumentUtil.registerGetRangeFromPointHandler(GoogleDocsUtil.getRangeFromPoint.bind(GoogleDocsUtil)); } } diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index a4cf6949..765d17d9 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -189,7 +189,6 @@ export class Backend { ['textHasJapaneseCharacters', this._onApiTextHasJapaneseCharacters.bind(this)], ['getTermFrequencies', this._onApiGetTermFrequencies.bind(this)], ['findAnkiNotes', this._onApiFindAnkiNotes.bind(this)], - ['loadExtensionScripts', this._onApiLoadExtensionScripts.bind(this)], ['openCrossFramePort', this._onApiOpenCrossFramePort.bind(this)] ]); /* eslint-enable no-multi-spaces */ @@ -846,17 +845,6 @@ export class Backend { return await this._anki.findNotes(query); } - /** @type {import('api').ApiHandler<'loadExtensionScripts'>} */ - async _onApiLoadExtensionScripts({files}, sender) { - if (!sender || !sender.tab) { throw new Error('Invalid sender'); } - const tabId = sender.tab.id; - if (typeof tabId !== 'number') { throw new Error('Sender has invalid tab ID'); } - const {frameId} = sender; - for (const file of files) { - await this._scriptManager.injectScript(file, tabId, frameId, false); - } - } - /** @type {import('api').ApiHandler<'openCrossFramePort'>} */ _onApiOpenCrossFramePort({targetTabId, targetFrameId}, sender) { const sourceTabId = (sender && sender.tab ? sender.tab.id : null); diff --git a/ext/js/comm/api.js b/ext/js/comm/api.js index f2d4d545..c0cfae16 100644 --- a/ext/js/comm/api.js +++ b/ext/js/comm/api.js @@ -355,14 +355,6 @@ export class API { } /** - * @param {import('api').ApiParam<'loadExtensionScripts', 'files'>} files - * @returns {Promise<import('api').ApiReturn<'loadExtensionScripts'>>} - */ - loadExtensionScripts(files) { - return this._invoke('loadExtensionScripts', {files}); - } - - /** * @param {import('api').ApiParam<'openCrossFramePort', 'targetTabId'>} targetTabId * @param {import('api').ApiParam<'openCrossFramePort', 'targetFrameId'>} targetFrameId * @returns {Promise<import('api').ApiReturn<'openCrossFramePort'>>} |