From 981f73b5623249b4c4cead0261eab0e70f620d90 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Mon, 25 Jan 2021 22:05:06 -0500 Subject: Clipboard lookup skip option (#1314) * Add autoSearchClipboardContent option * Hide header if there is any search text * Add setting for autoSearchClipboardContent * Add support for autoSearchClipboardContent --- ext/bg/js/search.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'ext/bg/js/search.js') diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js index 69edfabd..0fcbcd13 100644 --- a/ext/bg/js/search.js +++ b/ext/bg/js/search.js @@ -130,7 +130,7 @@ class DisplaySearch extends Display { case 'terms': case 'kanji': animate = !!content.animate; - valid = content.definitions.length > 0; + valid = (typeof source === 'string' && source.length > 0); this.blurElement(this._queryInput); break; case 'clear': @@ -159,12 +159,12 @@ class DisplaySearch extends Display { e.preventDefault(); e.stopImmediatePropagation(); this.blurElement(e.currentTarget); - this._search(true, true); + this._search(true, true, true); } _onSearch(e) { e.preventDefault(); - this._search(true, true); + this._search(true, true, true); } _onCopy() { @@ -173,12 +173,12 @@ class DisplaySearch extends Display { } _onExternalSearchUpdate({text, animate=true}) { - const {general: {maximumClipboardSearchLength}} = this.getOptions(); + const {general: {maximumClipboardSearchLength, autoSearchClipboardContent}} = this.getOptions(); if (text.length > maximumClipboardSearchLength) { text = text.substring(0, maximumClipboardSearchLength); } this._queryInput.value = text; - this._search(animate, false); + this._search(animate, false, autoSearchClipboardContent); } _onWanakanaEnableChange(e) { @@ -323,7 +323,7 @@ class DisplaySearch extends Display { }); } - _search(animate, history) { + _search(animate, history, lookup) { const query = this._queryInput.value; const depth = this.depth; const url = window.location.href; @@ -346,6 +346,7 @@ class DisplaySearch extends Display { animate } }; + if (!lookup) { details.params.lookup = 'false'; } this.setContent(details); } -- cgit v1.2.3