Last active
October 16, 2022 15:00
-
-
Save aurelienlair/2c1533093d371d9122d306aa43b2c223 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const XPATH_FILTER = "//*[contains(text(), '1º piano') or contains(text(), '2º piano') or contains(text(), '3º piano') or contains(text(), 'Piano rialzato')]/ancestor::article[contains(@class, 'item')]"; | |
const result = document.evaluate(XPATH_FILTER, document, null, XPathResult.ANY_TYPE, null); | |
try { | |
const nodesToBeRemoved = []; | |
let node = null; | |
while (node = result.iterateNext()) { | |
nodesToBeRemoved.push(node); | |
} | |
nodesToBeRemoved.forEach(nodeToBeRemove => nodeToBeRemove.remove()); | |
} catch (e) { | |
console.error('Error: during iteration ' + e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment