diff options
Diffstat (limited to 'ext')
-rw-r--r-- | ext/js/background/backend.js | 13 | ||||
-rw-r--r-- | ext/js/display/search-display-controller.js | 7 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index da720315..41989db3 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -314,6 +314,9 @@ export class Backend { * @param {import('clipboard-monitor').EventArgument<'change'>} details */ async _onClipboardTextChange({text}) { + // Only update if tab does not exist + if (await this._tabExists('/search.html')) { return; } + const { general: {language}, clipboard: {maximumSearchLength} @@ -1200,6 +1203,16 @@ export class Backend { } /** + * @param {string} urlParam + * @returns {Promise<boolean>} + */ + async _tabExists(urlParam) { + const baseUrl = chrome.runtime.getURL(urlParam); + const urlPredicate = (/** @type {?string} */ url) => url !== null && url.startsWith(baseUrl); + return await this._findSearchPopupTab(urlPredicate) !== null; + } + + /** * @param {string} url * @param {import('settings').ProfileOptions} options * @returns {chrome.windows.CreateData} diff --git a/ext/js/display/search-display-controller.js b/ext/js/display/search-display-controller.js index 815c51c9..62dbf343 100644 --- a/ext/js/display/search-display-controller.js +++ b/ext/js/display/search-display-controller.js @@ -66,11 +66,11 @@ export class SearchDisplayController { /** @type {boolean} */ this._clipboardMonitorEnabled = false; /** @type {import('clipboard-monitor').ClipboardReaderLike} */ - this.clipboardReaderLike = { + this._clipboardReaderLike = { getText: this._display.application.api.clipboardGet.bind(this._display.application.api) }; /** @type {ClipboardMonitor} */ - this._clipboardMonitor = new ClipboardMonitor(this.clipboardReaderLike); + this._clipboardMonitor = new ClipboardMonitor(this._clipboardReaderLike); /** @type {import('application').ApiMap} */ this._apiMap = createApiMap([ ['searchDisplayControllerGetMode', this._onMessageGetMode.bind(this)], @@ -271,7 +271,7 @@ export class SearchDisplayController { /** */ async _onCopy() { // Ignore copy from search page - this._clipboardMonitor.setPreviousText(document.hasFocus() ? await this.clipboardReaderLike.getText(false) : ''); + this._clipboardMonitor.setPreviousText(document.hasFocus() ? await this._clipboardReaderLike.getText(false) : ''); } /** @type {import('application').ApiHandler<'searchDisplayControllerUpdateSearchQuery'>} */ @@ -498,7 +498,6 @@ export class SearchDisplayController { */ _canEnableClipboardMonitor() { switch (this._searchPersistentStateController.mode) { - case 'popup': case 'action-popup': return false; default: |