diff --git a/src/background/commands.background.ts b/src/background/commands.background.ts
index 0b16f3b78a..9513904108 100644
--- a/src/background/commands.background.ts
+++ b/src/background/commands.background.ts
@@ -25,12 +25,11 @@ export default class CommandsBackground {
}
if (this.isSafari) {
- this.commands.addEventListener('message', async (msgEvent: any) => {
- const msg = msgEvent.message;
- if (msg.command === 'keyboardShortcutTriggered' && msg.command.shortcut) {
- await this.processCommand(msg.command.shortcut);
+ BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
+ if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
+ await this.processCommand(msg.shortcut);
}
- }, false);
+ });
} else {
this.commands.onCommand.addListener(async (command: any) => {
await this.processCommand(command);
@@ -38,13 +37,13 @@ export default class CommandsBackground {
}
}
- private async processCommand(command: string) {
+ private async processCommand(command: string, sender?: any) {
switch (command) {
case 'generate_password':
await this.generatePasswordToClipboard();
break;
case 'autofill_login':
- await this.autoFillLogin();
+ await this.autoFillLogin(sender ? sender.tab : null);
break;
case 'open_popup':
await this.openPopup();
@@ -55,6 +54,11 @@ export default class CommandsBackground {
}
private async generatePasswordToClipboard() {
+ if (this.isSafari) {
+ // Safari does not support access to clipboard from background
+ return;
+ }
+
const options = await this.passwordGenerationService.getOptions();
const password = await this.passwordGenerationService.generatePassword(options);
UtilsService.copyToClipboard(password);
@@ -66,8 +70,11 @@ export default class CommandsBackground {
});
}
- private async autoFillLogin() {
- const tab = await BrowserApi.getTabFromCurrentWindowId();
+ private async autoFillLogin(tab?: any) {
+ if (!tab) {
+ tab = await BrowserApi.getTabFromCurrentWindowId();
+ }
+
if (tab == null) {
return;
}
diff --git a/src/content/shortcuts.js b/src/content/shortcuts.js
index 7eb2940924..a8d30e06e9 100644
--- a/src/content/shortcuts.js
+++ b/src/content/shortcuts.js
@@ -19,7 +19,8 @@ document.addEventListener('DOMContentLoaded', (event) => {
arguments)}}(b))};c.init();r.Mousetrap=c;"undefined"!==typeof module&&module.exports&&(module.exports=c);"function"===typeof define&&define.amd&&define(function(){return c})}})("undefined"!==typeof window?window:null,"undefined"!==typeof window?document:null);
/* mousetrap v1.6.1 craig.is/killing/mice */
- Mousetrap.bind('mod+shift+l', () => {
+ const autofillCommand = isSafari ? 'mod+shift+l' : 'mod+shift+l';
+ Mousetrap.bind(autofillCommand, () => {
sendMessage('autofill_login');
});
@@ -27,9 +28,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
sendMessage('open_popup');
});
- Mousetrap.bind('mod+shift+9', () => {
- sendMessage('generate_password');
- });
+ if (!isSafari) {
+ Mousetrap.bind('mod+shift+9', () => {
+ sendMessage('generate_password');
+ });
+ }
function sendMessage(shortcut) {
if (isSafari) {
@@ -38,7 +41,7 @@ document.addEventListener('DOMContentLoaded', (event) => {
shortcut: shortcut
});
} else {
- // not supported at this time.
+ // other browsers not supported at this time.
}
}
});
diff --git a/src/safari/Info.plist b/src/safari/Info.plist
index cafafd43b3..8a82568ddd 100644
--- a/src/safari/Info.plist
+++ b/src/safari/Info.plist
@@ -64,6 +64,7 @@
content/autofill.js
content/autofiller.js
content/notificationBar.js
+ content/shortcuts.js
Stylesheets
diff --git a/webpack.common.js b/webpack.common.js
index bcc6b4699f..28e3af9eda 100644
--- a/webpack.common.js
+++ b/webpack.common.js
@@ -21,6 +21,7 @@ module.exports = {
'content/autofill': './src/content/autofill.js',
'content/autofiller': './src/content/autofiller.js',
'content/notificationBar': './src/content/notificationBar.js',
+ 'content/shortcuts': './src/content/shortcuts.js',
'notification/bar': './src/notification/bar.js',
'downloader/downloader': './src/downloader/downloader.ts',
},