feat: keyboard shortcuts for reveal mode and enable toggle

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
This commit is contained in:
Claude
2026-03-26 02:33:38 +00:00
parent 85c6647395
commit e7880b3b1a
3 changed files with 94 additions and 0 deletions
+16
View File
@@ -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": [
"<all_urls>"
],
+16
View File
@@ -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://*/*"
+62
View File
@@ -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' });