1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

[PS-1184] Remove specific keyboard shortcut logic (#3173)

* Removed logic for keyboard shortcuts specific to Vivaldi

* Removed shortcut.ts and related parts

* Removed dependency on mousetrap

* Safari: Remove sidebar_action and_execute_sidebar_action from manifest.json

* Rebuilt package-lock.json

* Fixed merge issue from pulling master
This commit is contained in:
Daniel James Smith
2022-09-08 14:48:45 +02:00
committed by GitHub
parent 3b69a60511
commit 28f8f245d9
8 changed files with 4 additions and 108 deletions

View File

@@ -61,7 +61,6 @@ function distFirefox() {
return dist("firefox", (manifest) => {
delete manifest.content_security_policy;
delete manifest.storage;
removeShortcuts(manifest);
return manifest;
});
}
@@ -70,7 +69,6 @@ function distOpera() {
return dist("opera", (manifest) => {
delete manifest.applications;
delete manifest.content_security_policy;
removeShortcuts(manifest);
return manifest;
});
}
@@ -95,15 +93,6 @@ function distEdge() {
});
}
function removeShortcuts(manifest) {
if (manifest.content_scripts && manifest.content_scripts.length > 1) {
const shortcutsScript = manifest.content_scripts[1];
if (shortcutsScript.js.indexOf("content/shortcuts.js") > -1) {
manifest.content_scripts.splice(1, 1);
}
}
}
function distSafariMas(cb) {
return distSafariApp(cb, "mas");
}
@@ -212,6 +201,8 @@ function safariCopyBuild(source, dest) {
gulpif(
"manifest.json",
jeditor((manifest) => {
delete manifest.sidebar_action;
delete manifest.commands._execute_sidebar_action;
delete manifest.optional_permissions;
manifest.permissions.push("nativeMessaging");
return manifest;

View File

@@ -34,14 +34,10 @@ export default class CommandsBackground {
msg.data.commandToRetry.sender
);
}
if (this.isVivaldi && msg.command === "keyboardShortcutTriggered" && msg.shortcut) {
await this.processCommand(msg.shortcut, sender);
}
}
);
if (!this.isVivaldi && chrome && chrome.commands) {
if (chrome && chrome.commands) {
chrome.commands.onCommand.addListener(async (command: string) => {
await this.processCommand(command);
});

View File

@@ -1,52 +0,0 @@
import * as Mousetrap from "mousetrap";
document.addEventListener("DOMContentLoaded", (event) => {
const isSafari =
typeof safari !== "undefined" &&
navigator.userAgent.indexOf(" Safari/") !== -1 &&
navigator.userAgent.indexOf("Chrome") === -1;
const isVivaldi = !isSafari && navigator.userAgent.indexOf(" Vivaldi/") !== -1;
if (!isSafari && !isVivaldi) {
return;
}
if (isSafari && (window as any).__bitwardenFrameId == null) {
(window as any).__bitwardenFrameId = Math.floor(Math.random() * Math.floor(99999999));
}
Mousetrap.prototype.stopCallback = () => {
return false;
};
let autofillCommand = ["mod+shift+l"];
if (isSafari) {
autofillCommand = ["mod+\\", "mod+8", "mod+shift+p"];
}
Mousetrap.bind(autofillCommand, () => {
sendMessage("autofill_login");
});
if (isSafari) {
Mousetrap.bind("mod+shift+y", () => {
sendMessage("open_popup");
});
Mousetrap.bind("mod+shift+s", () => {
sendMessage("lock_vault");
});
} else {
Mousetrap.bind("mod+shift+9", () => {
sendMessage("generate_password");
});
}
function sendMessage(shortcut: string) {
const msg: any = {
command: "keyboardShortcutTriggered",
shortcut: shortcut,
};
chrome.runtime.sendMessage(msg);
}
});

View File

@@ -26,12 +26,6 @@
"matches": ["http://*/*", "https://*/*", "file:///*"],
"run_at": "document_start"
},
{
"all_frames": false,
"js": ["content/shortcuts.js"],
"matches": ["http://*/*", "https://*/*", "file:///*"],
"run_at": "document_start"
},
{
"all_frames": false,
"js": ["content/message_handler.js"],

View File

@@ -27,12 +27,6 @@
"matches": ["http://*/*", "https://*/*", "file:///*"],
"run_at": "document_start"
},
{
"all_frames": false,
"js": ["content/shortcuts.js"],
"matches": ["http://*/*", "https://*/*", "file:///*"],
"run_at": "document_start"
},
{
"all_frames": false,
"js": ["content/message_handler.js"],

View File

@@ -136,7 +136,6 @@ const config = {
"content/autofiller": "./src/content/autofiller.ts",
"content/notificationBar": "./src/content/notificationBar.ts",
"content/contextMenuHandler": "./src/content/contextMenuHandler.ts",
"content/shortcuts": "./src/content/shortcuts.ts",
"content/message_handler": "./src/content/message_handler.ts",
"notification/bar": "./src/notification/bar.js",
},