From b88b97c054596c77a5a8bcc56b13412a3fe31be5 Mon Sep 17 00:00:00 2001 From: MarvNC Date: Mon, 1 Jul 2024 21:12:08 -0700 Subject: [PATCH] Don't scan alt text if option disabled --- ext/js/language/text-scanner.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 8582ea6600..759adf2047 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -449,6 +449,11 @@ export class TextScanner extends EventDispatcher { */ async _search(textSource, searchTerms, searchKanji, inputInfo, showEmpty = false) { try { + const isAltText = textSource instanceof TextSourceElement; + if (isAltText && !this._scanAltText) { + return; + } + const inputInfoDetail = inputInfo.detail; const selectionRestoreInfo = ( (typeof inputInfoDetail === 'object' && inputInfoDetail !== null && inputInfoDetail.restoreSelection) ? @@ -474,7 +479,7 @@ export class TextScanner extends EventDispatcher { const result = await this._findDictionaryEntries(textSource, searchTerms, searchKanji, optionsContext); if (result !== null) { ({dictionaryEntries, sentence, type} = result); - } else if (showEmpty || (textSource !== null && textSource instanceof TextSourceElement && await this._isTextLookupWorthy(textSource.fullContent))) { + } else if (showEmpty || (textSource !== null && isAltText && await this._isTextLookupWorthy(textSource.fullContent))) { // Shows a "No results found" message dictionaryEntries = []; sentence = {text: '', offset: 0};