Automatically fill credentials when site preference override for the setting is present

This commit is contained in:
AKORA 2024-10-06 20:43:50 +02:00
parent 9a07a9d7c5
commit 07ae4bd06a

View file

@ -501,15 +501,47 @@ kpxc.prepareCredentials = async function() {
return;
}
if (kpxc.settings.autoFillSingleEntry && kpxc.credentials.length === 1) {
if (kpxc.credentials.length === 1) {
if (kpxc.settings.autoFillSingleEntry) {
kpxcFill.fillFromAutofill();
return;
}
// Check for site preference overrides
const sitePreference = kpxc.retrieveSitePreference();
if (sitePreference !== null && sitePreference !== undefined) {
if (sitePreference.autoFillCredentials === true) {
kpxcFill.fillFromAutofill();
return;
}
}
}
kpxc.initLoginPopup();
kpxc.initAutocomplete();
};
kpxc.retrieveSitePreference = function() {
// Check for autofill site preferences
for (const site of kpxc.settings.sitePreferences) {
let currentLocation;
try {
currentLocation = window.top.location.href;
} catch (err) {
// Cross-domain security error inspecting window.top.location.href.
// This catches an error when an iframe is being accessed from another (sub)domain
// -> use the iframe URL instead.
currentLocation = window.self.location.href;
}
if (siteMatch(site.url, currentLocation) || site.url === currentLocation) {
return site;
}
}
return null;
}
/**
* Gets the credential list and shows the update banner
* @param {string} usernameValue Submitted username