Skip to content

Instantly share code, notes, and snippets.

@aurelienlair
Last active October 16, 2022 15:00
Show Gist options
  • Save aurelienlair/2c1533093d371d9122d306aa43b2c223 to your computer and use it in GitHub Desktop.
Save aurelienlair/2c1533093d371d9122d306aa43b2c223 to your computer and use it in GitHub Desktop.
{
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