summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/backend.js16
-rw-r--r--ext/bg/js/search-main.js4
-rw-r--r--ext/bg/js/search.js10
-rw-r--r--ext/bg/js/settings/popup-preview-frame-main.js4
-rw-r--r--ext/bg/js/settings/popup-preview-frame.js4
5 files changed, 24 insertions, 14 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index f1983cb3..fd90a220 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -525,8 +525,10 @@ class Backend {
}
_onApiFrameInformationGet(params, sender) {
+ const tab = sender.tab;
+ const tabId = tab ? tab.id : void 0;
const frameId = sender.frameId;
- return Promise.resolve({frameId});
+ return Promise.resolve({tabId, frameId});
}
_onApiInjectStylesheet({type, value}, sender) {
@@ -1505,17 +1507,17 @@ class Backend {
return isValidTab ? tab : null;
}
- async _getScreenshot(windowId, tabId, ownerFrameId, format, quality) {
+ async _getScreenshot(windowId, tabId, frameId, format, quality) {
if (typeof windowId !== 'number') {
throw new Error('Invalid window ID');
}
let token = null;
try {
- if (typeof tabId === 'number' && typeof ownerFrameId === 'number') {
+ if (typeof tabId === 'number' && typeof frameId === 'number') {
const action = 'setAllVisibleOverride';
const params = {value: false, priority: 0, awaitFrame: true};
- token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId: ownerFrameId});
+ token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
}
return await new Promise((resolve, reject) => {
@@ -1533,7 +1535,7 @@ class Backend {
const action = 'clearAllVisibleOverride';
const params = {token};
try {
- await this._sendMessageTabPromise(tabId, {action, params}, {frameId: ownerFrameId});
+ await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
} catch (e) {
// NOP
}
@@ -1634,8 +1636,8 @@ class Backend {
}
async _injectAnkNoteScreenshot(ankiConnect, timestamp, definitionDetails, details) {
- const {windowId, tabId, ownerFrameId, format, quality} = details;
- const dataUrl = await this._getScreenshot(windowId, tabId, ownerFrameId, format, quality);
+ const {windowId, tabId, frameId, format, quality} = details;
+ const dataUrl = await this._getScreenshot(windowId, tabId, frameId, format, quality);
const {mediaType, data} = this._getDataUrlInfo(dataUrl);
const extension = this._mediaUtility.getFileExtensionFromImageMediaType(mediaType);
diff --git a/ext/bg/js/search-main.js b/ext/bg/js/search-main.js
index 38c6f4dd..f6abdfc8 100644
--- a/ext/bg/js/search-main.js
+++ b/ext/bg/js/search-main.js
@@ -32,12 +32,14 @@
api.forwardLogsToBackend();
await yomichan.backendReady();
+ const {tabId, frameId} = await api.frameInformationGet();
+
const japaneseUtil = new JapaneseUtil(wanakana);
const hotkeyHandler = new HotkeyHandler();
hotkeyHandler.prepare();
- const displaySearch = new DisplaySearch(japaneseUtil, documentFocusController, hotkeyHandler);
+ const displaySearch = new DisplaySearch(tabId, frameId, japaneseUtil, documentFocusController, hotkeyHandler);
await displaySearch.prepare();
document.documentElement.dataset.loaded = 'true';
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index 27cba50f..dbc679b1 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -23,8 +23,8 @@
*/
class DisplaySearch extends Display {
- constructor(japaneseUtil, documentFocusController, hotkeyHandler) {
- super('search', japaneseUtil, documentFocusController, hotkeyHandler);
+ constructor(tabId, frameId, japaneseUtil, documentFocusController, hotkeyHandler) {
+ super('search', tabId, frameId, japaneseUtil, documentFocusController, hotkeyHandler);
this._searchButton = document.querySelector('#search-button');
this._queryInput = document.querySelector('#search-textbox');
this._introElement = document.querySelector('#intro');
@@ -353,7 +353,11 @@ class DisplaySearch extends Display {
},
content: {
definitions: null,
- animate
+ animate,
+ contentOrigin: {
+ tabId: this.tabId,
+ frameId: this.frameId
+ }
}
};
if (!lookup) { details.params.lookup = 'false'; }
diff --git a/ext/bg/js/settings/popup-preview-frame-main.js b/ext/bg/js/settings/popup-preview-frame-main.js
index 71454017..dcbc0d96 100644
--- a/ext/bg/js/settings/popup-preview-frame-main.js
+++ b/ext/bg/js/settings/popup-preview-frame-main.js
@@ -26,7 +26,7 @@
try {
api.forwardLogsToBackend();
- const {frameId} = await api.frameInformationGet();
+ const {tabId, frameId} = await api.frameInformationGet();
const hotkeyHandler = new HotkeyHandler();
hotkeyHandler.prepare();
@@ -34,7 +34,7 @@
const popupFactory = new PopupFactory(frameId);
popupFactory.prepare();
- const preview = new PopupPreviewFrame(frameId, popupFactory, hotkeyHandler);
+ const preview = new PopupPreviewFrame(tabId, frameId, popupFactory, hotkeyHandler);
await preview.prepare();
document.documentElement.dataset.loaded = 'true';
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js
index 73ac6caf..56100fb3 100644
--- a/ext/bg/js/settings/popup-preview-frame.js
+++ b/ext/bg/js/settings/popup-preview-frame.js
@@ -23,7 +23,8 @@
*/
class PopupPreviewFrame {
- constructor(frameId, popupFactory, hotkeyHandler) {
+ constructor(tabId, frameId, popupFactory, hotkeyHandler) {
+ this._tabId = tabId;
this._frameId = frameId;
this._popupFactory = popupFactory;
this._hotkeyHandler = hotkeyHandler;
@@ -67,6 +68,7 @@ class PopupPreviewFrame {
// Overwrite frontend
this._frontend = new Frontend({
+ tabId: this._tabId,
frameId: this._frameId,
popupFactory: this._popupFactory,
depth: 0,