Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

Add shortcuts link to Chrome (#834)

Leendert de Borst531fb2486fda
diff --git a/apps/browser-extension/src/entrypoints/background.ts b/apps/browser-extension/src/entrypoints/background.ts
index 1ddd6d785..640015cb4 100644
--- a/apps/browser-extension/src/entrypoints/background.ts
+++ b/apps/browser-extension/src/entrypoints/background.ts
@@ -1,10 +1,12 @@
import { defineBackground } from '#imports';
-import { onMessage } from "webext-bridge/background";
+import { onMessage, sendMessage } from "webext-bridge/background";
import { setupContextMenus } from '@/entrypoints/background/ContextMenu';
import { handleCheckAuthStatus, handleClearVault, handleCreateIdentity, handleGetCredentials, handleGetDefaultEmailDomain, handleGetDefaultIdentityLanguage, handleGetDerivedKey, handleGetPasswordSettings, handleGetVault, handleStoreVault, handleSyncVault } from '@/entrypoints/background/VaultMessageHandler';
import { handleOpenPopup, handlePopupWithCredential, handleToggleContextMenu } from '@/entrypoints/background/PopupMessageHandler';
import { storage } from '#imports';
import { GLOBAL_CONTEXT_MENU_ENABLED_KEY } from '@/utils/Constants';
+import { browser } from '#imports';
+
export default defineBackground({
/**
* This is the main entry point for the background script.
@@ -31,5 +33,42 @@ export default defineBackground({
if (isContextMenuEnabled) {
setupContextMenus();
}
+
+ // Listen for custom commands
+ try {
+ browser.commands.onCommand.addListener(async (command) => {
+ if (command === "show-autofill-popup") {
+ // Get the currently active tab
+ const [tab] = await browser.tabs.query({ active: true, currentWindow: true });
+ if (!tab?.id) {
+ return;
+ }
+
+ // Execute script in the active tab
+ await browser.scripting.executeScript({
+ target: { tabId: tab.id },
+ func: getActiveElementIdentifier,
+ }).then((results) => {
+ const elementIdentifier = results[0]?.result;
+ if (elementIdentifier) {
+ sendMessage('OPEN_AUTOFILL_POPUP', { elementIdentifier }, `content-script@${tab.id}`);
+ }
+ }).catch(console.error);
+ }
+ });
+ } catch (error) {
+ console.error('Error setting up command listener:', error);
+ }
+ }
+});
+
+/**
+ * Activate AliasVault for the active input element.
+ */
+function getActiveElementIdentifier() : string {
+ const target = document.activeElement;
+ if (target instanceof HTMLInputElement) {
+ return target.id || target.name || '';
}
-});
\ No newline at end of file
+ return '';
+}
\ No newline at end of file
diff --git a/apps/browser-extension/src/entrypoints/contentScript/style.css b/apps/browser-extension/src/entrypoints/contentScript/style.css
index b55d4c573..a35d6acd9 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/style.css
+++ b/apps/browser-extension/src/entrypoints/contentScript/style.css
@@ -196,6 +196,7 @@ body {
justify-content: center;
gap: 4px;
transition: background-color 0.2s ease;
+ min-width: 0px;
}
.av-button:hover {
@@ -231,6 +232,7 @@ body {
outline: none;
line-height: 1;
text-align: center;
+ min-width: 0px;
}
.av-search-input::placeholder {
diff --git a/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx b/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx
index cdf96cbd1..fe5e877c1 100644
--- a/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx
+++ b/apps/browser-extension/src/entrypoints/popup/pages/Settings.tsx
@@ -169,6 +169,25 @@ const Settings: React.FC = () => {
}));
};
+ /**
+ * Open keyboard shortcuts configuration page.
+ */
+ const openKeyboardShortcuts = async (): Promise<void> => {
+ // Detect browser type using user agent
+ const userAgent = navigator.userAgent.toLowerCase();
+ const isFirefox = userAgent.includes('firefox');
+ const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
+
+ if (isFirefox) {
+ await browser.tabs.create({ url: 'about:addons' });
+ } else if (isSafari) {
+ await browser.tabs.create({ url: 'safari-extension://shortcuts' });
+ } else {
+ // Chrome and other Chromium-based browsers
+ await browser.tabs.create({ url: 'chrome://extensions/shortcuts' });
+ }
+ };
+
return (
<div className="space-y-6">
<div className="flex justify-between items-center mb-4">
@@ -222,7 +241,7 @@ const Settings: React.FC = () => {
</section>
{/* Site-Specific Settings Section */}
- {settings.isGloballyEnabled ? (
+ {settings.isGloballyEnabled && (
<section>
<h3 className="text-md font-semibold text-gray-900 dark:text-white mb-3">Site-Specific Settings</h3>
<div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
@@ -264,7 +283,7 @@ const Settings: React.FC = () => {
</div>
</div>
</section>
- ) : (<></>)}
+ )}
{/* Appearance Settings Section */}
<section>
@@ -313,6 +332,28 @@ const Settings: React.FC = () => {
</div>
</section>
+ {/* Keyboard Shortcuts Section */}
+ {import.meta.env.CHROME && (
+ <section>
+ <h3 className="text-md font-semibold text-gray-900 dark:text-white mb-3">Keyboard Shortcuts</h3>
+ <div className="bg-white dark:bg-gray-800 rounded-lg shadow-sm border border-gray-200 dark:border-gray-700">
+ <div className="p-4">
+ <div className="flex items-center justify-between">
+ <div>
+ <p className="text-sm font-medium text-gray-900 dark:text-white">Configure keyboard shortcuts</p>
+ </div>
+ <button
+ onClick={openKeyboardShortcuts}
+ className="px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-md transition-colors"
+ >
+ Configure
+ </button>
+ </div>
+ </div>
+ </div>
+ </section>
+ )}
+
<div className="text-center text-gray-400 dark:text-gray-600">
Version: {AppInfo.VERSION}
</div>
diff --git a/apps/browser-extension/wxt.config.ts b/apps/browser-extension/wxt.config.ts
index 2109465fe..06b4b5e88 100644
--- a/apps/browser-extension/wxt.config.ts
+++ b/apps/browser-extension/wxt.config.ts
@@ -22,6 +22,11 @@ export default defineConfig({
host_permissions: [
"<all_urls>"
],
+ commands: {
+ "show-autofill-popup": {
+ description: "Show the autofill popup (while focusing an input field)"
+ }
+ }
},
modules: ['@wxt-dev/module-react'],
srcDir: 'src',