Merge pull request #66 from ajdor/master

Keyboard shortcuts and hotkeys
This commit is contained in:
Son Nguyen Kim
2020-09-12 11:05:52 +02:00
committed by GitHub
3 changed files with 32 additions and 2 deletions
+1 -1
View File
@@ -70,4 +70,4 @@ async function handleOnClickContextMenu(info, tab) {
generateAliasHandlerJS(tab, res);
}
export { handleOnClickContextMenu };
export { handleOnClickContextMenu, generateAliasHandlerJS };
+17 -1
View File
@@ -5,7 +5,10 @@ import Onboarding from "./onboarding";
import "./content-script";
import { handleNewRandomAlias } from "./create-alias";
import { handleOnClickContextMenu } from "./context-menu";
import {
handleOnClickContextMenu,
generateAliasHandlerJS,
} from "./context-menu";
import { firePermissionListener } from "./permissions";
global.isBackgroundJS = true;
@@ -46,5 +49,18 @@ browser.contextMenus.create({
onclick: handleOnClickContextMenu,
});
/**
* Shortcuts and hotkeys listener
*/
browser.commands.onCommand.addListener(async (command) => {
if (command === "generate-random-alias") {
const currentTab = (
await browser.tabs.query({ active: true, currentWindow: true })
)[0];
const res = await handleNewRandomAlias(currentTab.url);
generateAliasHandlerJS(currentTab, res);
}
});
APIService.initService();
Onboarding.initService();
+14
View File
@@ -33,5 +33,19 @@
"scripts": [
"background.js"
]
},
"commands": {
"generate-random-alias": {
"suggested_key": {
"default": "Ctrl+Shift+X"
},
"description": "Generate a random email alias"
},
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+S"
},
"description":"Open the extension action menu"
}
}
}