diff --git a/extension/src/popup/components/settings.ts b/extension/src/popup/components/settings.ts index 708464e..efcbd44 100644 --- a/extension/src/popup/components/settings.ts +++ b/extension/src/popup/components/settings.ts @@ -1,5 +1,5 @@ import { sendMessage, escapeHtml } from '../../shared/state'; -import type { VaultSettings } from '../../shared/types'; +import type { VaultSettings, DeviceSettings } from '../../shared/types'; import { loadColorScheme, saveColorScheme, resetColorScheme, DEFAULT_DIGIT_COLOR, DEFAULT_SYMBOL_COLOR, @@ -100,7 +100,78 @@ async function renderSection(section: SettingsSection): Promise { // --- Section stubs (filled in by Tasks 3-9) --- async function renderAutofillSection(content: HTMLElement): Promise { - content.innerHTML = '

Autofill — coming soon

'; + const [settingsResp, blacklistResp] = await Promise.all([ + sendMessage({ type: 'get_settings' }), + sendMessage({ type: 'get_blacklist' }), + ]); + + const settings: DeviceSettings = settingsResp.ok + ? (settingsResp.data as { settings: DeviceSettings }).settings + : { captureEnabled: false, captureStyle: 'bar' }; + + const blacklist: string[] = blacklistResp.ok + ? (blacklistResp.data as { blacklist: string[] }).blacklist + : []; + + content.innerHTML = ` +

Capture

+
+
+
Auto-detect logins
+
Show a prompt when a login form is detected.
+
+
+ +
+
+
+
+
Prompt style
+
How to prompt when a login is detected.
+
+
+ + +
+
+ +

Blocked sites

+
+ ${blacklist.length > 0 + ? blacklist.map((h) => ` +
+
+
${escapeHtml(h)}
+
+ +
+ `).join('') + : '

No blocked sites.

'} +
+ `; + + document.getElementById('capture-enabled')?.addEventListener('change', async (e) => { + const enabled = (e.target as HTMLInputElement).checked; + await sendMessage({ type: 'update_settings', settings: { captureEnabled: enabled } }); + }); + + document.getElementById('style-bar')?.addEventListener('click', async () => { + await sendMessage({ type: 'update_settings', settings: { captureStyle: 'bar' } }); + renderAutofillSection(content); + }); + + document.getElementById('style-toast')?.addEventListener('click', async () => { + await sendMessage({ type: 'update_settings', settings: { captureStyle: 'toast' } }); + renderAutofillSection(content); + }); + + content.querySelectorAll('.remove-bl').forEach((btn) => { + btn.addEventListener('click', async () => { + const host = btn.dataset.hostname!; + await sendMessage({ type: 'remove_blacklist', hostname: host }); + renderAutofillSection(content); + }); + }); } function renderDisplaySection(content: HTMLElement): void {