1
0
mirror of https://github.com/bitwarden/browser synced 2024-12-22 07:57:01 +01: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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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",
},

26
package-lock.json generated
View File

@ -47,7 +47,6 @@
"koa-json": "^2.0.2",
"lowdb": "^1.0.0",
"lunr": "^2.3.9",
"mousetrap": "^1.6.5",
"multer": "^1.4.5-lts.1",
"ngx-infinite-scroll": "^14.0.0",
"ngx-toastr": "^15.0.0",
@ -96,7 +95,6 @@
"@types/koa-json": "^2.0.20",
"@types/lowdb": "^1.0.11",
"@types/lunr": "^2.3.4",
"@types/mousetrap": "^1.6.8",
"@types/node": "^16.11.12",
"@types/node-fetch": "^2.6.1",
"@types/node-forge": "^1.0.2",
@ -12922,12 +12920,6 @@
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
"dev": true
},
"node_modules/@types/mousetrap": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/@types/mousetrap/-/mousetrap-1.6.9.tgz",
"integrity": "sha512-HUAiN65VsRXyFCTicolwb5+I7FM6f72zjMWr+ajGk+YTvzBgXqa2A5U7d+rtsouAkunJ5U4Sb5lNJjo9w+nmXg==",
"dev": true
},
"node_modules/@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
@ -31840,11 +31832,6 @@
"node": ">= 0.8"
}
},
"node_modules/mousetrap": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.5.tgz",
"integrity": "sha512-QNo4kEepaIBwiT8CDhP98umTetp+JNfQYBWvC1pc6/OAibuXtRcxZ58Qz8skvEHYvURne/7R8T5VoOI7rDsEUA=="
},
"node_modules/move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",
@ -47226,7 +47213,7 @@
"postcss": "^7.0.36",
"postcss-loader": "^4.2.0",
"raw-loader": "^4.0.2",
"react": "^18.0.0",
"react": "^16.14.0",
"react-dom": "^16.14.0",
"read-pkg-up": "^7.0.1",
"regenerator-runtime": "^0.13.7",
@ -52788,12 +52775,6 @@
"integrity": "sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==",
"dev": true
},
"@types/mousetrap": {
"version": "1.6.9",
"resolved": "https://registry.npmjs.org/@types/mousetrap/-/mousetrap-1.6.9.tgz",
"integrity": "sha512-HUAiN65VsRXyFCTicolwb5+I7FM6f72zjMWr+ajGk+YTvzBgXqa2A5U7d+rtsouAkunJ5U4Sb5lNJjo9w+nmXg==",
"dev": true
},
"@types/ms": {
"version": "0.7.31",
"resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.31.tgz",
@ -67511,11 +67492,6 @@
}
}
},
"mousetrap": {
"version": "1.6.5",
"resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.5.tgz",
"integrity": "sha512-QNo4kEepaIBwiT8CDhP98umTetp+JNfQYBWvC1pc6/OAibuXtRcxZ58Qz8skvEHYvURne/7R8T5VoOI7rDsEUA=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -60,7 +60,6 @@
"@types/koa-json": "^2.0.20",
"@types/lowdb": "^1.0.11",
"@types/lunr": "^2.3.4",
"@types/mousetrap": "^1.6.8",
"@types/node": "^16.11.12",
"@types/node-fetch": "^2.6.1",
"@types/node-forge": "^1.0.2",
@ -173,7 +172,6 @@
"koa-json": "^2.0.2",
"lowdb": "^1.0.0",
"lunr": "^2.3.9",
"mousetrap": "^1.6.5",
"multer": "^1.4.5-lts.1",
"ngx-infinite-scroll": "^14.0.0",
"ngx-toastr": "^15.0.0",