diff options
Diffstat (limited to 'ext/fg')
-rw-r--r-- | ext/fg/js/float.js | 9 | ||||
-rw-r--r-- | ext/fg/js/frontend.js | 8 |
2 files changed, 15 insertions, 2 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js index 74bc58b0..8c7de906 100644 --- a/ext/fg/js/float.js +++ b/ext/fg/js/float.js @@ -27,17 +27,24 @@ class DisplayFloat extends Display { url: window.location.href }; + this._orphaned = false; + + yomichan.on('orphaned', () => this.onOrphaned()); window.addEventListener('message', (e) => this.onMessage(e), false); } onError(error) { - if (window.yomichan_orphaned) { + if (this._orphaned) { this.setContentOrphaned(); } else { logError(error, true); } } + onOrphaned() { + this._orphaned = true; + } + onSearchClear() { window.parent.postMessage('popupClose', '*'); } diff --git a/ext/fg/js/frontend.js b/ext/fg/js/frontend.js index 1d63d928..6b41138f 100644 --- a/ext/fg/js/frontend.js +++ b/ext/fg/js/frontend.js @@ -37,6 +37,7 @@ class Frontend extends TextScanner { this.isPreparedPromiseResolve = null; this.isPreparedPromise = new Promise((resolve) => { this.isPreparedPromiseResolve = resolve; }); + this._orphaned = true; this._lastShowPromise = Promise.resolve(); } @@ -54,6 +55,7 @@ class Frontend extends TextScanner { try { await this.updateOptions(); + yomichan.on('orphaned', () => this.onOrphaned()); yomichan.on('optionsUpdate', () => this.updateOptions()); chrome.runtime.onMessage.addListener(this.onRuntimeMessage.bind(this)); this.isPreparedPromiseResolve(); @@ -93,6 +95,10 @@ class Frontend extends TextScanner { return false; } + onOrphaned() { + this._orphaned = true; + } + getMouseEventListeners() { return [ ...super.getMouseEventListeners(), @@ -122,7 +128,7 @@ class Frontend extends TextScanner { } } } catch (e) { - if (window.yomichan_orphaned) { + if (this._orphaned) { if (textSource !== null && this.options.scanning.modifier !== 'none') { this._lastShowPromise = this.popup.showContent( textSource.getRect(), |