From 82462edce0215e4de14ce7d9348304b2c2ca6a4d Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 7 Apr 2020 19:41:02 -0400 Subject: Add support for API handlers to be optionally asynchronous --- ext/bg/js/backend.js | 77 ++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 35 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 1fa7ede1..ed4a24ed 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -77,33 +77,33 @@ class Backend { this.messageToken = yomichan.generateId(16); this._messageHandlers = new Map([ - ['yomichanCoreReady', this._onApiYomichanCoreReady.bind(this)], - ['optionsSchemaGet', this._onApiOptionsSchemaGet.bind(this)], - ['optionsGet', this._onApiOptionsGet.bind(this)], - ['optionsGetFull', this._onApiOptionsGetFull.bind(this)], - ['optionsSet', this._onApiOptionsSet.bind(this)], - ['optionsSave', this._onApiOptionsSave.bind(this)], - ['kanjiFind', this._onApiKanjiFind.bind(this)], - ['termsFind', this._onApiTermsFind.bind(this)], - ['textParse', this._onApiTextParse.bind(this)], - ['textParseMecab', this._onApiTextParseMecab.bind(this)], - ['definitionAdd', this._onApiDefinitionAdd.bind(this)], - ['definitionsAddable', this._onApiDefinitionsAddable.bind(this)], - ['noteView', this._onApiNoteView.bind(this)], - ['templateRender', this._onApiTemplateRender.bind(this)], - ['commandExec', this._onApiCommandExec.bind(this)], - ['audioGetUri', this._onApiAudioGetUri.bind(this)], - ['screenshotGet', this._onApiScreenshotGet.bind(this)], - ['forward', this._onApiForward.bind(this)], - ['frameInformationGet', this._onApiFrameInformationGet.bind(this)], - ['injectStylesheet', this._onApiInjectStylesheet.bind(this)], - ['getEnvironmentInfo', this._onApiGetEnvironmentInfo.bind(this)], - ['clipboardGet', this._onApiClipboardGet.bind(this)], - ['getDisplayTemplatesHtml', this._onApiGetDisplayTemplatesHtml.bind(this)], - ['getQueryParserTemplatesHtml', this._onApiGetQueryParserTemplatesHtml.bind(this)], - ['getZoom', this._onApiGetZoom.bind(this)], - ['getMessageToken', this._onApiGetMessageToken.bind(this)], - ['getDefaultAnkiFieldTemplates', this._onApiGetDefaultAnkiFieldTemplates.bind(this)] + ['yomichanCoreReady', {handler: this._onApiYomichanCoreReady.bind(this), async: true}], + ['optionsSchemaGet', {handler: this._onApiOptionsSchemaGet.bind(this), async: true}], + ['optionsGet', {handler: this._onApiOptionsGet.bind(this), async: true}], + ['optionsGetFull', {handler: this._onApiOptionsGetFull.bind(this), async: true}], + ['optionsSet', {handler: this._onApiOptionsSet.bind(this), async: true}], + ['optionsSave', {handler: this._onApiOptionsSave.bind(this), async: true}], + ['kanjiFind', {handler: this._onApiKanjiFind.bind(this), async: true}], + ['termsFind', {handler: this._onApiTermsFind.bind(this), async: true}], + ['textParse', {handler: this._onApiTextParse.bind(this), async: true}], + ['textParseMecab', {handler: this._onApiTextParseMecab.bind(this), async: true}], + ['definitionAdd', {handler: this._onApiDefinitionAdd.bind(this), async: true}], + ['definitionsAddable', {handler: this._onApiDefinitionsAddable.bind(this), async: true}], + ['noteView', {handler: this._onApiNoteView.bind(this), async: true}], + ['templateRender', {handler: this._onApiTemplateRender.bind(this), async: true}], + ['commandExec', {handler: this._onApiCommandExec.bind(this), async: true}], + ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], + ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], + ['forward', {handler: this._onApiForward.bind(this), async: true}], + ['frameInformationGet', {handler: this._onApiFrameInformationGet.bind(this), async: true}], + ['injectStylesheet', {handler: this._onApiInjectStylesheet.bind(this), async: true}], + ['getEnvironmentInfo', {handler: this._onApiGetEnvironmentInfo.bind(this), async: true}], + ['clipboardGet', {handler: this._onApiClipboardGet.bind(this), async: true}], + ['getDisplayTemplatesHtml', {handler: this._onApiGetDisplayTemplatesHtml.bind(this), async: true}], + ['getQueryParserTemplatesHtml', {handler: this._onApiGetQueryParserTemplatesHtml.bind(this), async: true}], + ['getZoom', {handler: this._onApiGetZoom.bind(this), async: true}], + ['getMessageToken', {handler: this._onApiGetMessageToken.bind(this), async: true}], + ['getDefaultAnkiFieldTemplates', {handler: this._onApiGetDefaultAnkiFieldTemplates.bind(this), async: true}] ]); this._commandHandlers = new Map([ @@ -167,16 +167,23 @@ class Backend { } onMessage({action, params}, sender, callback) { - const handler = this._messageHandlers.get(action); - if (typeof handler !== 'function') { return false; } + const messageHandler = this._messageHandlers.get(action); + if (typeof messageHandler === 'undefined') { return false; } + + const {handler, async} = messageHandler; try { - const promise = handler(params, sender); - promise.then( - (result) => callback({result}), - (error) => callback({error: errorToJson(error)}) - ); - return true; + const promiseOrResult = handler(params, sender); + if (async) { + promiseOrResult.then( + (result) => callback({result}), + (error) => callback({error: errorToJson(error)}) + ); + return true; + } else { + callback({result: promiseOrResult}); + return false; + } } catch (error) { callback({error: errorToJson(error)}); return false; -- cgit v1.2.3 From 038e43d19dff736a818125db695699ad63437704 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 7 Apr 2020 19:47:46 -0400 Subject: Update some API handlers to be synchronous --- ext/bg/js/backend.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index ed4a24ed..8f494166 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -78,9 +78,9 @@ class Backend { this._messageHandlers = new Map([ ['yomichanCoreReady', {handler: this._onApiYomichanCoreReady.bind(this), async: true}], - ['optionsSchemaGet', {handler: this._onApiOptionsSchemaGet.bind(this), async: true}], - ['optionsGet', {handler: this._onApiOptionsGet.bind(this), async: true}], - ['optionsGetFull', {handler: this._onApiOptionsGetFull.bind(this), async: true}], + ['optionsSchemaGet', {handler: this._onApiOptionsSchemaGet.bind(this), async: false}], + ['optionsGet', {handler: this._onApiOptionsGet.bind(this), async: false}], + ['optionsGetFull', {handler: this._onApiOptionsGetFull.bind(this), async: false}], ['optionsSet', {handler: this._onApiOptionsSet.bind(this), async: true}], ['optionsSave', {handler: this._onApiOptionsSave.bind(this), async: true}], ['kanjiFind', {handler: this._onApiKanjiFind.bind(this), async: true}], @@ -91,7 +91,7 @@ class Backend { ['definitionsAddable', {handler: this._onApiDefinitionsAddable.bind(this), async: true}], ['noteView', {handler: this._onApiNoteView.bind(this), async: true}], ['templateRender', {handler: this._onApiTemplateRender.bind(this), async: true}], - ['commandExec', {handler: this._onApiCommandExec.bind(this), async: true}], + ['commandExec', {handler: this._onApiCommandExec.bind(this), async: false}], ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], ['forward', {handler: this._onApiForward.bind(this), async: true}], @@ -102,8 +102,8 @@ class Backend { ['getDisplayTemplatesHtml', {handler: this._onApiGetDisplayTemplatesHtml.bind(this), async: true}], ['getQueryParserTemplatesHtml', {handler: this._onApiGetQueryParserTemplatesHtml.bind(this), async: true}], ['getZoom', {handler: this._onApiGetZoom.bind(this), async: true}], - ['getMessageToken', {handler: this._onApiGetMessageToken.bind(this), async: true}], - ['getDefaultAnkiFieldTemplates', {handler: this._onApiGetDefaultAnkiFieldTemplates.bind(this), async: true}] + ['getMessageToken', {handler: this._onApiGetMessageToken.bind(this), async: false}], + ['getDefaultAnkiFieldTemplates', {handler: this._onApiGetDefaultAnkiFieldTemplates.bind(this), async: false}] ]); this._commandHandlers = new Map([ @@ -332,15 +332,15 @@ class Backend { }); } - async _onApiOptionsSchemaGet() { + _onApiOptionsSchemaGet() { return this.getOptionsSchema(); } - async _onApiOptionsGet({optionsContext}) { + _onApiOptionsGet({optionsContext}) { return this.getOptions(optionsContext); } - async _onApiOptionsGetFull() { + _onApiOptionsGetFull() { return this.getFullOptions(); } @@ -547,7 +547,7 @@ class Backend { return this._renderTemplate(template, data); } - async _onApiCommandExec({command, params}) { + _onApiCommandExec({command, params}) { return this._runCommand(command, params); } @@ -698,11 +698,11 @@ class Backend { }); } - async _onApiGetMessageToken() { + _onApiGetMessageToken() { return this.messageToken; } - async _onApiGetDefaultAnkiFieldTemplates() { + _onApiGetDefaultAnkiFieldTemplates() { return this.defaultAnkiFieldTemplates; } -- cgit v1.2.3 From 96566b8581549adba7cd24f37537fd7910eb8d37 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 7 Apr 2020 19:49:54 -0400 Subject: Update forward to be synchronous and ignore the reply --- ext/bg/js/backend.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 8f494166..31d29a20 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -94,7 +94,7 @@ class Backend { ['commandExec', {handler: this._onApiCommandExec.bind(this), async: false}], ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], - ['forward', {handler: this._onApiForward.bind(this), async: true}], + ['forward', {handler: this._onApiForward.bind(this), async: false}], ['frameInformationGet', {handler: this._onApiFrameInformationGet.bind(this), async: true}], ['injectStylesheet', {handler: this._onApiInjectStylesheet.bind(this), async: true}], ['getEnvironmentInfo', {handler: this._onApiGetEnvironmentInfo.bind(this), async: true}], @@ -569,13 +569,13 @@ class Backend { _onApiForward({action, params}, sender) { if (!(sender && sender.tab)) { - return Promise.resolve(); + return false; } const tabId = sender.tab.id; - return new Promise((resolve) => { - chrome.tabs.sendMessage(tabId, {action, params}, (response) => resolve(response)); - }); + const callback = () => this.checkLastError(chrome.runtime.lastError); + chrome.tabs.sendMessage(tabId, {action, params}, callback); + return true; } _onApiFrameInformationGet(params, sender) { -- cgit v1.2.3 From a2b66dc6cc3bd0d037c050eb49e270189a6617fb Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 7 Apr 2020 19:51:39 -0400 Subject: Rename apiForward to apiBroadcast --- ext/bg/js/backend.js | 4 ++-- ext/fg/js/float.js | 6 +++--- ext/fg/js/frame-offset-forwarder.js | 4 ++-- ext/fg/js/frontend-initialize.js | 4 ++-- ext/fg/js/frontend.js | 6 +++--- ext/mixed/js/api.js | 4 ++-- ext/mixed/js/display.js | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 31d29a20..c471c594 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -94,7 +94,7 @@ class Backend { ['commandExec', {handler: this._onApiCommandExec.bind(this), async: false}], ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], - ['forward', {handler: this._onApiForward.bind(this), async: false}], + ['broadcast', {handler: this._onApiBroadcast.bind(this), async: false}], ['frameInformationGet', {handler: this._onApiFrameInformationGet.bind(this), async: true}], ['injectStylesheet', {handler: this._onApiInjectStylesheet.bind(this), async: true}], ['getEnvironmentInfo', {handler: this._onApiGetEnvironmentInfo.bind(this), async: true}], @@ -567,7 +567,7 @@ class Backend { }); } - _onApiForward({action, params}, sender) { + _onApiBroadcast({action, params}, sender) { if (!(sender && sender.tab)) { return false; } diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 01055ca6..8c00d0a5 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -18,7 +18,7 @@ /* global * Display - * apiForward + * apiBroadcast * apiGetMessageToken * popupNestedInitialize */ @@ -80,7 +80,7 @@ class DisplayFloat extends Display { this.setContentScale(scale); - apiForward('popupPrepareCompleted', {targetPopupId: this._popupId}); + apiBroadcast('popupPrepareCompleted', {targetPopupId: this._popupId}); } onError(error) { @@ -181,7 +181,7 @@ class DisplayFloat extends Display { }, 2000 ); - apiForward('requestDocumentInformationBroadcast', {uniqueId}); + apiBroadcast('requestDocumentInformationBroadcast', {uniqueId}); const {title} = await promise; return title; diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js index 7b417b6e..88c1b72c 100644 --- a/ext/fg/js/frame-offset-forwarder.js +++ b/ext/fg/js/frame-offset-forwarder.js @@ -17,7 +17,7 @@ */ /* global - * apiForward + * apiBroadcast */ class FrameOffsetForwarder { @@ -97,6 +97,6 @@ class FrameOffsetForwarder { } _forwardFrameOffsetOrigin(offset, uniqueId) { - apiForward('frameOffset', {offset, uniqueId}); + apiBroadcast('frameOffset', {offset, uniqueId}); } } diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index 4a1409db..d2572746 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -21,7 +21,7 @@ * Frontend * PopupProxy * PopupProxyHost - * apiForward + * apiBroadcast * apiOptionsGet */ @@ -44,7 +44,7 @@ async function main() { } } ); - apiForward('rootPopupRequestInformationBroadcast'); + apiBroadcast('rootPopupRequestInformationBroadcast'); const {popupId, frameId} = await rootPopupInformationPromise; const frameOffsetForwarder = new FrameOffsetForwarder(); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 31843212..bcb0b84a 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -18,7 +18,7 @@ /* global * TextScanner - * apiForward + * apiBroadcast * apiGetZoom * apiKanjiFind * apiOptionsGet @@ -261,12 +261,12 @@ class Frontend extends TextScanner { _broadcastRootPopupInformation() { if (!this.popup.isProxy() && this.popup.depth === 0) { - apiForward('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId}); + apiBroadcast('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId}); } } _broadcastDocumentInformation(uniqueId) { - apiForward('documentInformationBroadcast', { + apiBroadcast('documentInformationBroadcast', { uniqueId, frameId: this.popup.frameId, title: document.title diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index feec94df..d28e3ab6 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -81,8 +81,8 @@ function apiScreenshotGet(options) { return _apiInvoke('screenshotGet', {options}); } -function apiForward(action, params) { - return _apiInvoke('forward', {action, params}); +function apiBroadcast(action, params) { + return _apiInvoke('broadcast', {action, params}); } function apiFrameInformationGet() { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 2f456c3e..710674b2 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -23,9 +23,9 @@ * DisplayGenerator * WindowScroll * apiAudioGetUri + * apiBroadcast * apiDefinitionAdd * apiDefinitionsAddable - * apiForward * apiKanjiFind * apiNoteView * apiOptionsGet @@ -855,7 +855,7 @@ class Display { } setPopupVisibleOverride(visible) { - return apiForward('popupSetVisibleOverride', {visible}); + return apiBroadcast('popupSetVisibleOverride', {visible}); } setSpinnerVisible(visible) { -- cgit v1.2.3 From c88ec43ad1523fefaa47b6e46dd0fa95f342559c Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Tue, 7 Apr 2020 19:59:10 -0400 Subject: Fix yomichanCoreReady waiting for a response --- ext/bg/js/backend.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index c471c594..35e75bbe 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -77,7 +77,7 @@ class Backend { this.messageToken = yomichan.generateId(16); this._messageHandlers = new Map([ - ['yomichanCoreReady', {handler: this._onApiYomichanCoreReady.bind(this), async: true}], + ['yomichanCoreReady', {handler: this._onApiYomichanCoreReady.bind(this), async: false}], ['optionsSchemaGet', {handler: this._onApiOptionsSchemaGet.bind(this), async: false}], ['optionsGet', {handler: this._onApiOptionsGet.bind(this), async: false}], ['optionsGetFull', {handler: this._onApiOptionsGetFull.bind(this), async: false}], @@ -320,16 +320,15 @@ class Backend { _onApiYomichanCoreReady(_params, sender) { // tab ID isn't set in background (e.g. browser_action) + const callback = () => this.checkLastError(chrome.runtime.lastError); + const data = {action: 'backendPrepared'}; if (typeof sender.tab === 'undefined') { - const callback = () => this.checkLastError(chrome.runtime.lastError); - chrome.runtime.sendMessage({action: 'backendPrepared'}, callback); - return Promise.resolve(); + chrome.runtime.sendMessage(data, callback); + return false; + } else { + chrome.tabs.sendMessage(sender.tab.id, data, callback); + return true; } - - const tabId = sender.tab.id; - return new Promise((resolve) => { - chrome.tabs.sendMessage(tabId, {action: 'backendPrepared'}, resolve); - }); } _onApiOptionsSchemaGet() { -- cgit v1.2.3 From a296c758b95b428777548f5aada1be13429faf03 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 10 Apr 2020 20:00:18 -0400 Subject: apiBroadcast => apiBroadcastTab --- ext/bg/js/backend.js | 4 ++-- ext/fg/js/float.js | 6 +++--- ext/fg/js/frame-offset-forwarder.js | 4 ++-- ext/fg/js/frontend-initialize.js | 4 ++-- ext/fg/js/frontend.js | 6 +++--- ext/mixed/js/api.js | 4 ++-- ext/mixed/js/display.js | 4 ++-- 7 files changed, 16 insertions(+), 16 deletions(-) (limited to 'ext/bg') diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 35e75bbe..20e17836 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -94,7 +94,7 @@ class Backend { ['commandExec', {handler: this._onApiCommandExec.bind(this), async: false}], ['audioGetUri', {handler: this._onApiAudioGetUri.bind(this), async: true}], ['screenshotGet', {handler: this._onApiScreenshotGet.bind(this), async: true}], - ['broadcast', {handler: this._onApiBroadcast.bind(this), async: false}], + ['broadcastTab', {handler: this._onApiBroadcastTab.bind(this), async: false}], ['frameInformationGet', {handler: this._onApiFrameInformationGet.bind(this), async: true}], ['injectStylesheet', {handler: this._onApiInjectStylesheet.bind(this), async: true}], ['getEnvironmentInfo', {handler: this._onApiGetEnvironmentInfo.bind(this), async: true}], @@ -566,7 +566,7 @@ class Backend { }); } - _onApiBroadcast({action, params}, sender) { + _onApiBroadcastTab({action, params}, sender) { if (!(sender && sender.tab)) { return false; } diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 8c00d0a5..d0c0f419 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -18,7 +18,7 @@ /* global * Display - * apiBroadcast + * apiBroadcastTab * apiGetMessageToken * popupNestedInitialize */ @@ -80,7 +80,7 @@ class DisplayFloat extends Display { this.setContentScale(scale); - apiBroadcast('popupPrepareCompleted', {targetPopupId: this._popupId}); + apiBroadcastTab('popupPrepareCompleted', {targetPopupId: this._popupId}); } onError(error) { @@ -181,7 +181,7 @@ class DisplayFloat extends Display { }, 2000 ); - apiBroadcast('requestDocumentInformationBroadcast', {uniqueId}); + apiBroadcastTab('requestDocumentInformationBroadcast', {uniqueId}); const {title} = await promise; return title; diff --git a/ext/fg/js/frame-offset-forwarder.js b/ext/fg/js/frame-offset-forwarder.js index 88c1b72c..609d0d77 100644 --- a/ext/fg/js/frame-offset-forwarder.js +++ b/ext/fg/js/frame-offset-forwarder.js @@ -17,7 +17,7 @@ */ /* global - * apiBroadcast + * apiBroadcastTab */ class FrameOffsetForwarder { @@ -97,6 +97,6 @@ class FrameOffsetForwarder { } _forwardFrameOffsetOrigin(offset, uniqueId) { - apiBroadcast('frameOffset', {offset, uniqueId}); + apiBroadcastTab('frameOffset', {offset, uniqueId}); } } diff --git a/ext/fg/js/frontend-initialize.js b/ext/fg/js/frontend-initialize.js index d2572746..5c9ce7b1 100644 --- a/ext/fg/js/frontend-initialize.js +++ b/ext/fg/js/frontend-initialize.js @@ -21,7 +21,7 @@ * Frontend * PopupProxy * PopupProxyHost - * apiBroadcast + * apiBroadcastTab * apiOptionsGet */ @@ -44,7 +44,7 @@ async function main() { } } ); - apiBroadcast('rootPopupRequestInformationBroadcast'); + apiBroadcastTab('rootPopupRequestInformationBroadcast'); const {popupId, frameId} = await rootPopupInformationPromise; const frameOffsetForwarder = new FrameOffsetForwarder(); diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index bcb0b84a..b380dbfd 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -18,7 +18,7 @@ /* global * TextScanner - * apiBroadcast + * apiBroadcastTab * apiGetZoom * apiKanjiFind * apiOptionsGet @@ -261,12 +261,12 @@ class Frontend extends TextScanner { _broadcastRootPopupInformation() { if (!this.popup.isProxy() && this.popup.depth === 0) { - apiBroadcast('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId}); + apiBroadcastTab('rootPopupInformation', {popupId: this.popup.id, frameId: this.popup.frameId}); } } _broadcastDocumentInformation(uniqueId) { - apiBroadcast('documentInformationBroadcast', { + apiBroadcastTab('documentInformationBroadcast', { uniqueId, frameId: this.popup.frameId, title: document.title diff --git a/ext/mixed/js/api.js b/ext/mixed/js/api.js index d28e3ab6..83a4a403 100644 --- a/ext/mixed/js/api.js +++ b/ext/mixed/js/api.js @@ -81,8 +81,8 @@ function apiScreenshotGet(options) { return _apiInvoke('screenshotGet', {options}); } -function apiBroadcast(action, params) { - return _apiInvoke('broadcast', {action, params}); +function apiBroadcastTab(action, params) { + return _apiInvoke('broadcastTab', {action, params}); } function apiFrameInformationGet() { diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js index 710674b2..b691ae12 100644 --- a/ext/mixed/js/display.js +++ b/ext/mixed/js/display.js @@ -23,7 +23,7 @@ * DisplayGenerator * WindowScroll * apiAudioGetUri - * apiBroadcast + * apiBroadcastTab * apiDefinitionAdd * apiDefinitionsAddable * apiKanjiFind @@ -855,7 +855,7 @@ class Display { } setPopupVisibleOverride(visible) { - return apiBroadcast('popupSetVisibleOverride', {visible}); + return apiBroadcastTab('popupSetVisibleOverride', {visible}); } setSpinnerVisible(visible) { -- cgit v1.2.3