Merge pull request #2430 from keepassxreboot/fix/add_shadow_dom_exceptions

Add exceptions for Shadow DOM input query
This commit is contained in:
Sami Vänttinen 2025-01-07 07:54:52 +02:00 committed by GitHub
commit 60355e8e1c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -101,6 +101,16 @@ kpxcSites.exceptionFound = function(identifier, field) {
return false;
};
// Forbids using Shadow DOM query with some sites unless a login dialog has been identified
kpxcSites.isShadowDomQueryAllowed = function(nodeName) {
if (document.location.href?.startsWith('https://www.reddit.com')
&& nodeName !== 'BODY'
&& !document.querySelector('auth-flow-manager[step-name=login]')) {
return false;
}
return true;
};
/**
* Handles a few exceptions for certain sites where 2FA field is not regognized properly.
* @param {object} field Input field Element

View file

@ -170,7 +170,7 @@ kpxcObserverHelper.getInputs = function(target, ignoreVisibility = false) {
inputFields.push(target);
}
if (kpxc.improvedFieldDetectionEnabledForPage) {
if (kpxc.improvedFieldDetectionEnabledForPage && kpxcSites.isShadowDomQueryAllowed(target?.nodeName)) {
const inputFieldsFromShadowDOM = kpxcObserverHelper.findInputsFromShadowDOM(target);
if (inputFieldsFromShadowDOM.length > 0) {
logDebug('Input fields from Shadow DOM found:', inputFieldsFromShadowDOM);