Use active element on fillFromCombination()

This commit is contained in:
varjolintu 2023-09-16 10:51:56 +03:00
parent f3379e6677
commit 29991bf8ea

View file

@ -30,26 +30,26 @@ kpxcFill.fillInFromActiveElement = async function(passOnly = false) {
return;
}
const elem = document.activeElement;
if (kpxc.combinations.length > 0) {
if (await kpxcFill.fillFromCombination(passOnly)) {
if (await kpxcFill.fillFromCombination(elem, passOnly)) {
// Combination found and filled
return;
}
}
// No previous combinations detected. Create a new one from active element
const el = document.activeElement;
const combination = await kpxc.createCombination(el, passOnly);
const combination = await kpxc.createCombination(elem, passOnly);
await sendMessage('page_set_login_id', kpxc.credentials[0].uuid);
kpxcFill.fillInCredentials(combination, kpxc.credentials[0].login, kpxc.credentials[0].uuid, passOnly);
};
// Fill from combination, if found
kpxcFill.fillFromCombination = async function(passOnly) {
kpxcFill.fillFromCombination = async function(elem, passOnly) {
const combination = passOnly
? kpxc.combinations.find(c => c.password)
: kpxc.combinations.find(c => c.username);
? kpxc.combinations.find(c => c.password === elem)
: kpxc.combinations.find(c => c.username === elem);
if (!combination) {
logDebug('Error: No combination found.');
return false;