summaryrefslogtreecommitdiff
path: root/ext/js/background/backend.js
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-05-28 15:32:56 -0400
committerGitHub <noreply@github.com>2024-05-28 19:32:56 +0000
commit3bfd56bbe46a4f2ee9c66f0c7baeec3c6292718c (patch)
tree668f8ce77c043308ad4d6c57911931ef03565bf1 /ext/js/background/backend.js
parentb414e3f1fa351c0754b1fc9e0ee33bef7e1962d3 (diff)
Fix clipboard monitor in popups (#1003)
* Fix naming of _clipboardReaderLike * Allow clipboard monitors in popup searches * Only run _onClipboardTextChange if a search tab does not exist
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r--ext/js/background/backend.js13
1 files changed, 13 insertions, 0 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}