-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: centralize settings and add background initialization
- Add background script to initialize settings on install - Centralize default settings in constants.ts - Move ExtensionSettings interface to types.ts - Update TypeScript configurations for better organization - Ensure extension works without opening popup first
- Loading branch information
Showing
14 changed files
with
114 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
async function initializeSettings() { | ||
const data = await browser.storage.local.get('settings'); | ||
if (!data.settings) { | ||
await browser.storage.local.set({ | ||
settings: DEFAULT_SETTINGS | ||
}); | ||
console.log('[NTM-Debug] Settings initialized with default values'); | ||
} | ||
} | ||
|
||
// Initialize settings when extension is installed or updated | ||
browser.runtime.onInstalled.addListener(initializeSettings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Default settings as a constant | ||
const DEFAULT_SETTINGS: ExtensionSettings = { | ||
titleTranslation: true, | ||
audioTranslation: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,2 @@ | ||
declare const browser: typeof import('webextension-polyfill'); | ||
|
||
interface ExtensionSettings { | ||
titleTranslation: boolean; | ||
audioTranslation: boolean; | ||
} | ||
declare const browser: typeof import('webextension-polyfill'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2020", | ||
"module": "none", | ||
"moduleResolution": "node", | ||
"strict": true, | ||
"outFile": "./dist/background/background.js", | ||
"rootDir": "./src", | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"isolatedModules": false, | ||
"noEmit": false, | ||
"noEmitHelpers": true, | ||
"typeRoots": [ | ||
"./node_modules/@types", | ||
"./src/types" | ||
], | ||
"types": ["webextension-polyfill"] | ||
}, | ||
"files": [ | ||
"src/types/global.d.ts", | ||
"src/types/types.ts", | ||
"src/config/constants.ts", | ||
"src/background/background.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters