Add browser save and update workflow
This commit is contained in:
@@ -396,6 +396,22 @@ function fillCredential(credential, targetDescriptor) {
|
||||
return { ok: true };
|
||||
}
|
||||
|
||||
function submittedCredential(candidate, rawURL) {
|
||||
if (!candidate?.passwordInput) {
|
||||
return null;
|
||||
}
|
||||
const password = String(candidate.passwordInput.value || "").trim();
|
||||
if (!password) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
title: domainLabel(rawURL),
|
||||
username: String(candidate.usernameInput?.value || "").trim(),
|
||||
password,
|
||||
url: String(rawURL || "").trim()
|
||||
};
|
||||
}
|
||||
|
||||
function domainLabel(rawURL) {
|
||||
try {
|
||||
return new URL(rawURL).host || "";
|
||||
@@ -447,7 +463,8 @@ const contentTestExports = {
|
||||
fieldHintText,
|
||||
scopeHintText,
|
||||
hasAuthFlowSignals,
|
||||
authFlowCandidate
|
||||
authFlowCandidate,
|
||||
submittedCredential
|
||||
};
|
||||
|
||||
if (isNodeTestEnv) {
|
||||
@@ -805,6 +822,23 @@ if (isNodeTestEnv) {
|
||||
scheduleRefresh(false);
|
||||
}, true);
|
||||
|
||||
document.addEventListener("submit", (event) => {
|
||||
const form = event.target instanceof HTMLFormElement ? event.target : null;
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
const passwordInput = visibleInputs(form).find(isPasswordCandidate) || null;
|
||||
const candidate = passwordInput ? authFlowCandidate(passwordInput) : null;
|
||||
const observed = submittedCredential(candidate, window.location.href);
|
||||
if (!observed) {
|
||||
return;
|
||||
}
|
||||
void runtimeSend({
|
||||
type: "keepassgo-observed-login",
|
||||
observed
|
||||
}).catch(() => null);
|
||||
}, true);
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!root.contains(event.target)) {
|
||||
chooserOpen = false;
|
||||
|
||||
Reference in New Issue
Block a user