Skip to content

Commit

Permalink
Don't scan alt text if option disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
MarvNC committed Jul 2, 2024
1 parent 0f3447a commit b88b97c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/js/language/text-scanner.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) ?
Expand All @@ -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};
Expand Down

0 comments on commit b88b97c

Please sign in to comment.