Skip to content

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

Make autofill popup show logic more robust (#834)

Leendert de Borstb03a2f5da62b
diff --git a/apps/browser-extension/src/entrypoints/content.ts b/apps/browser-extension/src/entrypoints/content.ts
index c54faa7b4..14deba41e 100644
--- a/apps/browser-extension/src/entrypoints/content.ts
+++ b/apps/browser-extension/src/entrypoints/content.ts
@@ -22,13 +22,14 @@ export default defineContentScript({
return;
}
+ // Wait for 750ms to give the host page time to load and to increase the chance that the body is available and ready.
+ await new Promise(resolve => setTimeout(resolve, 750));
+
// Create a shadow root UI for isolation
const ui = await createShadowRootUi(ctx, {
name: 'aliasvault-ui',
- position: 'overlay',
- alignment: 'top-left',
- zIndex: 2147483646,
- anchor: 'html',
+ position: 'inline',
+ anchor: 'body',
/**
* Handle mount.
*/
@@ -69,6 +70,12 @@ export default defineContentScript({
// Listen for input field focus in the main document
document.addEventListener('focusin', handleFocusIn);
+ // Check if currently something is focused, if so, apply check for that element
+ const currentFocusedElement = document.activeElement;
+ if (currentFocusedElement) {
+ showPopupForElement(currentFocusedElement);
+ }
+
// Listen for popstate events (back/forward navigation)
window.addEventListener('popstate', () => {
if (ctx.isInvalid) {
@@ -88,22 +95,31 @@ export default defineContentScript({
}
const target = document.getElementById(elementIdentifier) ?? document.getElementsByName(elementIdentifier)[0];
- const { isValid, inputElement } = validateInputField(target);
+
+ showPopupForElement(target);
+
+ return { success: true };
+ });
+
+ /**
+ * Show popup for element.
+ */
+ function showPopupForElement(element: Element) : void {
+ const { isValid, inputElement } = validateInputField(element);
if (!isValid || !inputElement) {
- return { success: false, error: 'Target element is not a supported input field' };
+ return;
}
const formDetector = new FormDetector(document, inputElement);
if (!formDetector.containsLoginForm()) {
- return { success: false, error: 'No form found' };
+ return;
}
// This is an explicit call by the user to open the popup, so we don't check if it's enabled.
injectIcon(inputElement, container);
openAutofillPopup(inputElement, container);
- return { success: true };
- });
+ }
},
});
diff --git a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
index f7013bb2d..4afdae779 100644
--- a/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
+++ b/apps/browser-extension/src/entrypoints/contentScript/Popup.ts
@@ -345,13 +345,13 @@ export function createAutofillPopup(input: HTMLInputElement, credentials: Creden
<svg class="av-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
- Dismiss for 1 hour (current site)
+ Hide for 1 hour (current site)
</button>
<button class="av-context-menu-item" data-action="permanent">
<svg class="av-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M6 18L18 6M6 6l12 12" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
- Dismiss permanently (current site)
+ Hide permanently (current site)
</button>
`;
diff --git a/docs/misc/dev/browser-extensions.md b/docs/misc/dev/browser-extensions.md
index 3ec79b883..5df4a33a8 100644
--- a/docs/misc/dev/browser-extensions.md
+++ b/docs/misc/dev/browser-extensions.md
@@ -113,3 +113,5 @@ The following websites have been known to cause issues in the past (but should b
| [Microsoft Online](https://login.microsoftonline.com/) | Password gets reset after autofill |
| [ING Bank](https://mijn.ing.nl/login/) | Autofill doesn't detect input fields and AliasVault autofill icon placement is off |
| [GitHub Issues](https://github.com/lanedirt/AliasVault/issues) | The "New issue -> Blank Issue" title field causes the autofill to trigger because of a parent form (outside of the role=modal div) |
+| [Netim](https://www.netim.com/direct/) | Autofill popup not showing up |
+| [ChatGPT login](https://auth.openai.com/log-in) | Autofill popup not showing up |
\ No newline at end of file