From e7880b3b1a6b01a59fe44cb731a078f3ce61befe Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Mar 2026 02:33:38 +0000 Subject: [PATCH] feat: keyboard shortcuts for reveal mode and enable toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alt+Shift+R — toggle reveal mode (fake→real in responses) Alt+Shift+S — toggle Silent Send on/off Badge flashes "EYE" (blue) when reveal activates, "ON"/"OFF" (green/red) when toggling enabled state. Users can remap these in chrome://extensions/shortcuts or Firefox about:addons. https://claude.ai/code/session_01Dvgwe7XMoSxnWXkih8p1Cw --- manifest.firefox.json | 16 +++++++++ manifest.json | 16 +++++++++ src/background/service-worker.js | 62 ++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) diff --git a/manifest.firefox.json b/manifest.firefox.json index b71637c..d9eb096 100644 --- a/manifest.firefox.json +++ b/manifest.firefox.json @@ -63,6 +63,22 @@ "48": "icons/icon48.svg", "128": "icons/icon128.svg" }, + "commands": { + "toggle-reveal": { + "suggested_key": { + "default": "Alt+Shift+R", + "mac": "Alt+Shift+R" + }, + "description": "Toggle Reveal Mode" + }, + "toggle-enabled": { + "suggested_key": { + "default": "Alt+Shift+S", + "mac": "Alt+Shift+S" + }, + "description": "Toggle Silent Send on/off" + } + }, "optional_permissions": [ "" ], diff --git a/manifest.json b/manifest.json index d73537b..c66096a 100644 --- a/manifest.json +++ b/manifest.json @@ -54,6 +54,22 @@ "48": "icons/icon48.svg", "128": "icons/icon128.svg" }, + "commands": { + "toggle-reveal": { + "suggested_key": { + "default": "Alt+Shift+R", + "mac": "Alt+Shift+R" + }, + "description": "Toggle Reveal Mode" + }, + "toggle-enabled": { + "suggested_key": { + "default": "Alt+Shift+S", + "mac": "Alt+Shift+S" + }, + "description": "Toggle Silent Send on/off" + } + }, "optional_host_permissions": [ "https://*/*", "http://*/*" diff --git a/src/background/service-worker.js b/src/background/service-worker.js index d619b18..3034780 100644 --- a/src/background/service-worker.js +++ b/src/background/service-worker.js @@ -168,6 +168,68 @@ const messageHandlers = { }, }; +// --- Keyboard Shortcuts --- +api.commands.onCommand.addListener(async (command) => { + const settings = await Storage.getSettings(); + + if (command === 'toggle-reveal') { + settings.revealMode = !settings.revealMode; + await Storage.saveSettings({ revealMode: settings.revealMode }); + + // Broadcast to all tabs + broadcastSettings(settings); + + // Show brief badge text + const [tab] = await api.tabs.query({ active: true, currentWindow: true }); + if (tab) { + api.action.setBadgeText({ text: settings.revealMode ? 'EYE' : '', tabId: tab.id }); + api.action.setBadgeBackgroundColor({ + color: settings.revealMode ? '#1d4ed8' : '#6b7280', + tabId: tab.id, + }); + if (!settings.revealMode) { + // Restore normal badge after a moment + setTimeout(() => updateBadge(tab.id), 1500); + } + } + } + + if (command === 'toggle-enabled') { + settings.enabled = !settings.enabled; + await Storage.saveSettings({ enabled: settings.enabled }); + + broadcastSettings(settings); + + // Flash badge + const [tab] = await api.tabs.query({ active: true, currentWindow: true }); + if (tab) { + api.action.setBadgeText({ text: settings.enabled ? 'ON' : 'OFF', tabId: tab.id }); + api.action.setBadgeBackgroundColor({ + color: settings.enabled ? '#10b981' : '#dc2626', + tabId: tab.id, + }); + setTimeout(() => updateBadge(tab.id), 1500); + } + } +}); + +async function broadcastSettings(settings) { + const allPatterns = [...BUILTIN_URL_PATTERNS]; + const customDomains = settings.customDomains || []; + for (const domain of customDomains) { + allPatterns.push(domain + '/*'); + } + for (const urlPattern of allPatterns) { + const tabs = await api.tabs.query({ url: urlPattern }).catch(() => []); + for (const tab of tabs) { + api.tabs.sendMessage(tab.id, { + type: 'settings:updated', + settings, + }).catch(() => {}); + } + } +} + // --- Set initial badge state --- api.runtime.onInstalled.addListener(() => { api.action.setBadgeBackgroundColor({ color: '#6b7280' });