Enhance element extraction by including hidden containers and shadow DOM elements in the DOM processing logic

This commit is contained in:
seb
2025-07-17 06:02:09 +02:00
parent f44b66b152
commit fe99fb8e5f

View File

@@ -964,7 +964,31 @@ class TestExecutor {
} }
// Start from body and extract all relevant elements // Start from body and extract all relevant elements
return processContainer(document.body); // Also check the entire document for elements that might be in hidden containers
const bodyResults = processContainer(document.body);
// Additionally, search the entire document for our target elements
// This catches elements that might be in hidden containers or shadow DOM
const allElements = document.querySelectorAll(keepElements.join(','));
const additionalResults = [];
allElements.forEach(element => {
const processed = processElement(element);
if (processed) {
// Check if this element is already in bodyResults
const alreadyExists = bodyResults.some(existing =>
existing.tag === processed.tag &&
existing.attributes.id === processed.attributes.id &&
existing.attributes.class === processed.attributes.class
);
if (!alreadyExists) {
additionalResults.push(processed);
}
}
});
return [...bodyResults, ...additionalResults];
}); });
// Convert to readable HTML format // Convert to readable HTML format