diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 6c5975b8c6..7b7ae34c6d 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -463,6 +463,7 @@ "length", "deepDomScan", "scanAltText", + "scanHyperlinkText", "popupNestingMaxDepth", "enablePopupSearch", "enableOnPopupExpressions", @@ -720,6 +721,10 @@ "type": "boolean", "default": true }, + "scanHyperlinkText": { + "type": "boolean", + "default": true + }, "popupNestingMaxDepth": { "type": "integer", "minimum": 0, diff --git a/ext/js/app/frontend.js b/ext/js/app/frontend.js index 858f690d5f..38a47b94c8 100644 --- a/ext/js/app/frontend.js +++ b/ext/js/app/frontend.js @@ -519,7 +519,11 @@ export class Frontend { }); this._updateTextScannerEnabled(); - if (this._pageType !== 'web') { + if (this._pageType === 'web') { + if (!scanningOptions.scanHyperlinkText) { + this._textScanner.excludeSelector = 'a,a *'; + } + } else { const excludeSelectors = ['.scan-disable', '.scan-disable *']; if (!scanningOptions.enableOnPopupExpressions) { excludeSelectors.push('.source-text', '.source-text *'); diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 9ee0e16c21..b83e5da4d8 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -563,6 +563,7 @@ export class OptionsUtil { this._updateVersion49, this._updateVersion50, this._updateVersion51, + this._updateVersion52, ]; /* eslint-enable @typescript-eslint/unbound-method */ if (typeof targetVersion === 'number' && targetVersion < result.length) { @@ -1487,6 +1488,16 @@ export class OptionsUtil { } } + /** + * - Added scanning.scanAltText + * @type {import('options-util').UpdateFunction} + */ + async _updateVersion52(options) { + for (const profile of options.profiles) { + profile.options.scanning.scanHyperlinkText = true; + } + } + /** * @param {string} url * @returns {Promise} @@ -1503,6 +1514,7 @@ export class OptionsUtil { }); }); } + } /* eslint-enable @typescript-eslint/no-unsafe-assignment */ diff --git a/ext/js/display/display.js b/ext/js/display/display.js index b121b1631b..b18a84e5f3 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -465,6 +465,7 @@ export class Display extends EventDispatcher { matchTypePrefix: false, sentenceParsingOptions, scanAltText: scanningOptions.scanAltText, + scanHyperlinkText: scanningOptions.scanHyperlinkText, scanWithoutMousemove: scanningOptions.scanWithoutMousemove, scanResolution: scanningOptions.scanResolution, }, @@ -2034,6 +2035,7 @@ export class Display extends EventDispatcher { preventMiddleMouse: false, sentenceParsingOptions, scanAltText: scanningOptions.scanAltText, + scanHyperlinkText: scanningOptions.scanHyperlinkText, }); this._contentTextScanner.setEnabled(true); diff --git a/ext/settings.html b/ext/settings.html index 3df2e1b235..e86fb81fe2 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -486,6 +486,14 @@

Yomitan Settings

+
+
+
Scan hyperlink text
+
+
+ +
+
diff --git a/test/options-util.test.js b/test/options-util.test.js index 0eca28cea0..8c1362f8f9 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -349,6 +349,7 @@ function createProfileOptionsUpdatedTestData1() { hidePopupOnCursorExitDelay: 0, normalizeCssZoom: true, scanAltText: true, + scanHyperlinkText: true, preventMiddleMouse: { onWebPages: false, onPopupPages: false, @@ -645,7 +646,7 @@ function createOptionsUpdatedTestData1() { }, ], profileCurrent: 0, - version: 51, + version: 52, global: { database: { prefixWildcardsSupported: false, diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index c29c47f0e4..3f6cd09adf 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -15,6 +15,7 @@ * along with this program. If not, see . */ +import type * as TextScanner from './text-scanner'; import type * as Input from './input'; export type OptionsContextFlag = 'clipboard'; @@ -27,6 +28,7 @@ export type OptionsContext1 = { flags?: OptionsContextFlag[]; modifiers?: Input.Modifier[]; modifierKeys?: Input.ModifierKey[]; + pointerType?: TextScanner.PointerType; }; export type OptionsContext2 = { @@ -37,6 +39,7 @@ export type OptionsContext2 = { flags?: OptionsContextFlag[]; modifiers?: Input.Modifier[]; modifierKeys?: Input.ModifierKey[]; + pointerType?: TextScanner.PointerType; }; export type OptionsContext3 = { @@ -47,6 +50,7 @@ export type OptionsContext3 = { flags?: OptionsContextFlag[]; modifiers?: Input.Modifier[]; modifierKeys?: Input.ModifierKey[]; + pointerType?: TextScanner.PointerType; }; export type OptionsContext = OptionsContext1 | OptionsContext2 | OptionsContext3; @@ -195,6 +199,7 @@ export type ScanningOptions = { hidePopupOnCursorExitDelay: number; normalizeCssZoom: boolean; scanAltText: boolean; + scanHyperlinkText: boolean; scanWithoutMousemove: boolean; scanResolution: string; }; diff --git a/types/ext/text-scanner.d.ts b/types/ext/text-scanner.d.ts index bc660d6e31..84d4a5b895 100644 --- a/types/ext/text-scanner.d.ts +++ b/types/ext/text-scanner.d.ts @@ -42,6 +42,7 @@ export type Options = { matchTypePrefix?: boolean; sentenceParsingOptions?: SentenceParsingOptions; scanAltText?: boolean; + scanHyperlinkText?: boolean; scanWithoutMousemove?: boolean; scanResolution?: string; };