From e3bb9d9b7e137d0dbcc14f20159ffe897cfd5d5d Mon Sep 17 00:00:00 2001 From: UnluckyNinja Date: Tue, 3 Dec 2024 16:59:32 +0800 Subject: [PATCH] feat: added full translate mode --- .gitattributes | 3 + __mocks__/$.ts | 11 +++ src/components/Options.vue | 25 ++++++- src/map.fflate | 2 +- src/misc/dawg/index.ts | 42 ++++++----- src/misc/dawg/trie.ts | 8 +- src/misc/gameText.test.ts | 27 +++++++ src/misc/gameText.ts | 16 ++-- src/misc/scanner.ts | 150 +++++++++++++++++++++++++++---------- src/misc/store.ts | 3 + src/translation/index.ts | 32 ++++++++ src/trie.fflate | 2 +- vitest.config.ts | 23 +++++- 13 files changed, 271 insertions(+), 73 deletions(-) create mode 100644 .gitattributes create mode 100644 __mocks__/$.ts create mode 100644 src/misc/gameText.test.ts create mode 100644 src/translation/index.ts diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..908988d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf + +*.fflate -diff linguist-generated=true \ No newline at end of file diff --git a/__mocks__/$.ts b/__mocks__/$.ts new file mode 100644 index 0000000..fe1c3af --- /dev/null +++ b/__mocks__/$.ts @@ -0,0 +1,11 @@ + +const store = new Map() +export function GM_deleteValue(key){ + store.delete(key) +} +export function GM_getValue(key){ + store.get(key) +} +export function GM_setValue(key, value) { + store.set(key, value) +} \ No newline at end of file diff --git a/src/components/Options.vue b/src/components/Options.vue index 5c95a5a..8cc2514 100644 --- a/src/components/Options.vue +++ b/src/components/Options.vue @@ -8,6 +8,7 @@ import { Tabs, TabsList, TabsTrigger } from './ui/tabs'; const { enableGoogleTranslate, + translateMode, customTranslations, matchSelectors, katakanaLanguage, @@ -36,6 +37,14 @@ function removeSelector(k: number) { matchSelectors.value.splice(k) } +function updateMode(value: boolean){ + if(value) { + translateMode.value = 'full' + } else { + translateMode.value = 'katakana' + } +} +