diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 8ac279798c..c3022908d1 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -513,6 +513,7 @@ export class Frontend { matchTypePrefix: scanningOptions.matchTypePrefix, preventMiddleMouse, sentenceParsingOptions, + scanAltText: scanningOptions.scanAltText, }); this._updateTextScannerEnabled(); diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 8af299d8e2..bd409fcab6 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -349,6 +349,7 @@ export class OptionsUtil { enableOnSearchPage: true, enableSearchTags: false, layoutAwareScan: false, + scanAltText: true, }, translation: { diff --git a/ext/js/display/display.js b/ext/js/display/display.js index 3d18e41609..014063826c 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -461,6 +461,7 @@ export class Display extends EventDispatcher { preventMiddleMouse: scanningOptions.preventMiddleMouse.onSearchQuery, matchTypePrefix: false, sentenceParsingOptions, + scanAltText: scanningOptions.scanAltText, }, }); @@ -1984,6 +1985,7 @@ export class Display extends EventDispatcher { layoutAwareScan: scanningOptions.layoutAwareScan, preventMiddleMouse: false, sentenceParsingOptions, + scanAltText: scanningOptions.scanAltText, }); this._contentTextScanner.setEnabled(true); diff --git a/ext/js/language/text-scanner.js b/ext/js/language/text-scanner.js index 249a2eda3d..8582ea6600 100644 --- a/ext/js/language/text-scanner.js +++ b/ext/js/language/text-scanner.js @@ -124,6 +124,8 @@ export class TextScanner extends EventDispatcher { this._sentenceBackwardQuoteMap = new Map(); /** @type {import('text-scanner').InputConfig[]} */ this._inputs = []; + /** @type {boolean} */ + this._scanAltText = true; /** @type {boolean} */ this._enabled = false; @@ -255,6 +257,7 @@ export class TextScanner extends EventDispatcher { preventMiddleMouse, sentenceParsingOptions, matchTypePrefix, + scanAltText, }) { if (Array.isArray(inputs)) { this._inputs = inputs.map((input) => this._convertInput(input)); @@ -289,6 +292,9 @@ export class TextScanner extends EventDispatcher { if (typeof matchTypePrefix === 'boolean') { this._matchTypePrefix = matchTypePrefix; } + if (typeof scanAltText === 'boolean') { + this._scanAltText = scanAltText; + } if (typeof sentenceParsingOptions === 'object' && sentenceParsingOptions !== null) { const {scanExtent, terminationCharacterMode, terminationCharacters} = sentenceParsingOptions; if (typeof scanExtent === 'number') { diff --git a/ext/settings.html b/ext/settings.html index dfd562a9ca..ccd6dc9b93 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -415,6 +415,15 @@

Yomitan Settings

+
+
+
Scan alt text
+
Scan text that is used for image and button descriptions.
+
+
+ +
+
diff --git a/test/options-util.test.js b/test/options-util.test.js index 253b965067..f3e52a1537 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -95,6 +95,7 @@ function createProfileOptionsTestData1() { enableOnSearchPage: true, enableSearchTags: false, layoutAwareScan: false, + scanAltText: true, }, translation: { convertHalfWidthCharacters: 'false', @@ -325,6 +326,7 @@ function createProfileOptionsUpdatedTestData1() { hidePopupOnCursorExit: false, hidePopupOnCursorExitDelay: 0, normalizeCssZoom: true, + scanAltText: true, preventMiddleMouse: { onWebPages: false, onPopupPages: false, diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index 559a27c425..b84942b174 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -190,6 +190,7 @@ export type ScanningOptions = { hidePopupOnCursorExit: boolean; hidePopupOnCursorExitDelay: number; normalizeCssZoom: boolean; + scanAltText: boolean; }; export type ScanningInput = { diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index 4277d49afc..0af55d72a7 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -41,6 +41,7 @@ export type Options = { preventMiddleMouse?: boolean; matchTypePrefix?: boolean; sentenceParsingOptions?: SentenceParsingOptions; + scanAltText?: boolean; }; export type InputOptionsOuter = {