feat: bypass validation check shadow dom
This commit is contained in:
@@ -336,7 +336,7 @@ export const BrowserWindow = () => {
|
|||||||
const listElements = evaluateXPathAllWithShadowSupport(
|
const listElements = evaluateXPathAllWithShadowSupport(
|
||||||
iframeElement.contentDocument!,
|
iframeElement.contentDocument!,
|
||||||
listSelector,
|
listSelector,
|
||||||
listSelector.includes('>>') || listSelector.startsWith('//')
|
listSelector.includes(">>") || listSelector.startsWith("//")
|
||||||
).slice(0, 10);
|
).slice(0, 10);
|
||||||
|
|
||||||
if (listElements.length < 2) {
|
if (listElements.length < 2) {
|
||||||
@@ -346,13 +346,36 @@ export const BrowserWindow = () => {
|
|||||||
const validSelectors: string[] = [];
|
const validSelectors: string[] = [];
|
||||||
|
|
||||||
for (const selector of selectors) {
|
for (const selector of selectors) {
|
||||||
|
// First, try to access the element directly
|
||||||
|
try {
|
||||||
|
const testElement = iframeElement.contentDocument!.evaluate(
|
||||||
|
selector,
|
||||||
|
iframeElement.contentDocument!,
|
||||||
|
null,
|
||||||
|
XPathResult.FIRST_ORDERED_NODE_TYPE,
|
||||||
|
null
|
||||||
|
).singleNodeValue;
|
||||||
|
|
||||||
|
// If we can't access the element, it's likely in shadow DOM - include it
|
||||||
|
if (!testElement) {
|
||||||
|
console.log(`Including potentially shadow DOM selector: ${selector}`);
|
||||||
|
validSelectors.push(selector);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (accessError) {
|
||||||
|
// If there's an error accessing, assume shadow DOM and include it
|
||||||
|
console.log(`Including selector due to access error: ${selector}`);
|
||||||
|
validSelectors.push(selector);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
let occurrenceCount = 0;
|
let occurrenceCount = 0;
|
||||||
|
|
||||||
// Get all elements that match this child selector
|
// Get all elements that match this child selector
|
||||||
const childElements = evaluateXPathAllWithShadowSupport(
|
const childElements = evaluateXPathAllWithShadowSupport(
|
||||||
iframeElement.contentDocument!,
|
iframeElement.contentDocument!,
|
||||||
selector,
|
selector,
|
||||||
selector.includes('>>') || selector.startsWith('//')
|
selector.includes(">>") || selector.startsWith("//")
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check how many of these child elements are contained within our list elements
|
// Check how many of these child elements are contained within our list elements
|
||||||
|
|||||||
Reference in New Issue
Block a user