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

View File

@ -12,6 +12,15 @@ export default function createManifest(
page: 'options/index.html',
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 = {