diff options
Diffstat (limited to 'ext/js/background')
-rw-r--r-- | ext/js/background/backend.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 79023ac9..6340d021 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -34,8 +34,8 @@ import {arrayBufferToBase64} from '../data/sandbox/array-buffer-util.js'; import {DictionaryDatabase} from '../dictionary/dictionary-database.js'; import {Environment} from '../extension/environment.js'; import {ObjectPropertyAccessor} from '../general/object-property-accessor.js'; -import {distributeFuriganaInflected, isCodePointJapanese, isStringPartiallyJapanese, convertKatakanaToHiragana as jpConvertKatakanaToHiragana} from '../language/ja/japanese.js'; -import {getLanguageSummaries} from '../language/languages.js'; +import {distributeFuriganaInflected, isCodePointJapanese, convertKatakanaToHiragana as jpConvertKatakanaToHiragana} from '../language/ja/japanese.js'; +import {getLanguageSummaries, isTextLookupWorthy} from '../language/languages.js'; import {Translator} from '../language/translator.js'; import {AudioDownloader} from '../media/audio-downloader.js'; import {getFileExtensionFromAudioMediaType, getFileExtensionFromImageMediaType} from '../media/media-util.js'; @@ -175,7 +175,7 @@ export class Backend { ['isTabSearchPopup', this._onApiIsTabSearchPopup.bind(this)], ['triggerDatabaseUpdated', this._onApiTriggerDatabaseUpdated.bind(this)], ['testMecab', this._onApiTestMecab.bind(this)], - ['textHasJapaneseCharacters', this._onApiTextHasJapaneseCharacters.bind(this)], + ['isTextLookupWorthy', this._onApiIsTextLookupWorthy.bind(this)], ['getTermFrequencies', this._onApiGetTermFrequencies.bind(this)], ['findAnkiNotes', this._onApiFindAnkiNotes.bind(this)], ['openCrossFramePort', this._onApiOpenCrossFramePort.bind(this)], @@ -310,7 +310,11 @@ export class Backend { * @param {import('clipboard-monitor').EventArgument<'change'>} details */ async _onClipboardTextChange({text}) { - const {clipboard: {maximumSearchLength}} = this._getProfileOptions({current: true}, false); + const { + general: {language}, + clipboard: {maximumSearchLength} + } = this._getProfileOptions({current: true}, false); + if (!isTextLookupWorthy(text, language)) { return; } if (text.length > maximumSearchLength) { text = text.substring(0, maximumSearchLength); } @@ -839,9 +843,9 @@ export class Backend { return true; } - /** @type {import('api').ApiHandler<'textHasJapaneseCharacters'>} */ - _onApiTextHasJapaneseCharacters({text}) { - return isStringPartiallyJapanese(text); + /** @type {import('api').ApiHandler<'isTextLookupWorthy'>} */ + _onApiIsTextLookupWorthy({text, language}) { + return isTextLookupWorthy(text, language); } /** @type {import('api').ApiHandler<'getTermFrequencies'>} */ |