Disable passkeys script injection if site is ignored

This commit is contained in:
varjolintu 2025-03-28 19:47:54 +02:00
parent 44e8b45cc6
commit e11d63df5f
4 changed files with 24 additions and 0 deletions

View file

@ -264,6 +264,7 @@ kpxcEvent.messageHandlers = {
'init_http_auth': kpxcEvent.initHttpAuth,
'is_connected': kpxcEvent.getIsKeePassXCAvailable,
'is_iframe_allowed': page.isIframeAllowed,
'is_site_ignored': page.isSiteIgnored,
'load_keyring': kpxcEvent.onLoadKeyRing,
'load_settings': kpxcEvent.onLoadSettings,
'lock_database': kpxcEvent.lockDatabase,

View file

@ -320,6 +320,22 @@ page.fillHttpAuth = async function(tab, credentials) {
}
};
page.isSiteIgnored = async function(tab, currentLocation) {
if (!page?.settings?.sitePreferences || !currentLocation) {
return false;
}
for (const site of page.settings.sitePreferences) {
if (siteMatch(site.url, currentLocation) || site.url === currentLocation) {
if (site.ignore === IGNORE_FULL) {
return true;
}
}
}
return false;
};
// Update context menu for attribute filling
page.updateContextMenu = async function(tab, credentials) {
// Remove any old attribute items

View file

@ -981,6 +981,8 @@ browser.runtime.onMessage.addListener(async function(req, sender) {
}
} else if (req.action === 'ignore_site') {
kpxc.ignoreSite(req.args);
} else if (req.action === 'is_site_ignored') {
return await kpxc.siteIgnored();
} else if (req.action === 'redetect_fields') {
const response = await sendMessage('load_settings');
kpxc.settings = response;

View file

@ -99,6 +99,11 @@ const initContent = async () => {
return;
}
if (await chrome.runtime.sendMessage({ action: 'is_site_ignored', args: window.self.location.href })) {
console.log('This site is ignored in Site Preferences.');
return;
}
if (settings.passkeys) {
kpxcPasskeysUtils.debugLogging = settings?.debugLogging;
kpxcPasskeysUtils.passkeysFallback = settings?.passkeysFallback;