{
window.__xpath_target?.forEach?.((n) => {
if (n.nodeName == "#text") {
n = n.parentElement;
}
n.classList.remove("xpath-highlight");
});
const t1 = Date.now();
const xpathResult = document.evaluate(
xpath,
document,
null,
XPathResult.ANY_TYPE,
null
);
let nodes = [];
let node = null;
while ((node = xpathResult.iterateNext())) {
nodes.push(node);
}
nodes.forEach((n) => {
if (n.nodeName == "#text") {
n = n.parentElement;
}
n.classList.add("xpath-highlight");
});
window.__xpath_target = nodes;
return nodes;
}