Add a keyboard shortcut to toggle all redirects, default Alt+Shift+R.

This commit is contained in:
Bauke 2022-11-21 13:25:00 +01:00
parent 6bd5bccd6f
commit 48a29eea71
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
3 changed files with 19 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import {toggleAllRedirects} from '../utilities/toggle-all-redirects.js';
export async function onCommandsHandler(command: string): Promise<void> {
if (command === 'toggleAllRedirects') {
await toggleAllRedirects();
}
}

View File

@ -2,6 +2,7 @@ import browser from 'webextension-polyfill';
import storage from '../redirect/storage.js'; import storage from '../redirect/storage.js';
import {updateBadge} from '../utilities/badge.js'; import {updateBadge} from '../utilities/badge.js';
import {onCommandsHandler} from './commands.js';
import { import {
contextClicked, contextClicked,
getContextMenus, getContextMenus,
@ -97,6 +98,8 @@ browser.contextMenus.onClicked.addListener(async (info, tab) => {
await contextClicked(contextMenuIds, info, tab); await contextClicked(contextMenuIds, info, tab);
}); });
browser.commands.onCommand.addListener(onCommandsHandler);
if (import.meta.env.VITE_BROWSER === 'chromium') { if (import.meta.env.VITE_BROWSER === 'chromium') {
browser.action.onClicked.addListener(browserActionClicked); browser.action.onClicked.addListener(browserActionClicked);
} else { } else {

View File

@ -12,6 +12,15 @@ export default function createManifest(
page: 'options/index.html', page: 'options/index.html',
open_in_tab: true, open_in_tab: true,
}, },
commands: {
toggleAllRedirects: {
description:
"Toggle all redirects, this does the same as the extension icon's right-click option.",
suggested_key: {
default: 'Alt+Shift+R',
},
},
},
}; };
const icons = { const icons = {