aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js14
1 files changed, 9 insertions, 5 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index a6b9c0dc..21b18e99 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -112,7 +112,7 @@ class Backend {
['getDisplayTemplatesHtml', {async: true, contentScript: true, handler: this._onApiGetDisplayTemplatesHtml.bind(this)}],
['getZoom', {async: true, contentScript: true, handler: this._onApiGetZoom.bind(this)}],
['getDefaultAnkiFieldTemplates', {async: false, contentScript: true, handler: this._onApiGetDefaultAnkiFieldTemplates.bind(this)}],
- ['getDictionaryInfo', {async: true, contentScript: false, handler: this._onApiGetDictionaryInfo.bind(this)}],
+ ['getDictionaryInfo', {async: true, contentScript: true, handler: this._onApiGetDictionaryInfo.bind(this)}],
['getDictionaryCounts', {async: true, contentScript: false, handler: this._onApiGetDictionaryCounts.bind(this)}],
['purgeDatabase', {async: true, contentScript: false, handler: this._onApiPurgeDatabase.bind(this)}],
['getMedia', {async: true, contentScript: true, handler: this._onApiGetMedia.bind(this)}],
@@ -1288,10 +1288,14 @@ class Backend {
}
_validatePrivilegedMessageSender(sender) {
- const url = sender.url;
- if (!(typeof url === 'string' && yomichan.isExtensionUrl(url))) {
- throw new Error('Invalid message sender');
- }
+ let {url} = sender;
+ if (typeof url === 'string' && yomichan.isExtensionUrl(url)) { return; }
+ const {tab} = url;
+ if (typeof tab === 'object' && tab !== null) {
+ ({url} = tab);
+ if (typeof url === 'string' && yomichan.isExtensionUrl(url)) { return; }
+ }
+ throw new Error('Invalid message sender');
}
_getBrowserIconTitle() {