Skip to content

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

Merge branch 'main' into 834-add-extra-enabledisable-setting-toggles-to-browser-extension

Leendert de Borst183130fd3e53
diff --cc apps/browser-extension/src/entrypoints/background.ts
index 640015cb4,1ddd6d785..f93b39731
--- a/apps/browser-extension/src/entrypoints/background.ts
+++ b/apps/browser-extension/src/entrypoints/background.ts
@@@ -3,10 -3,8 +3,9 @@@ import { onMessage, sendMessage } from
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 { storage, browser } 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.
@@@ -33,42 -31,5 +32,42 @@@
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 || '';
}
-});
+ return '';
+}