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:
@@ -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' });
|
||||
|
||||
Reference in New Issue
Block a user