Skip to content

Instantly share code, notes, and snippets.

@lylejantzi3rd
Created November 7, 2023 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lylejantzi3rd/e7861052c5231e2e440e95729d19bcaa to your computer and use it in GitHub Desktop.
Save lylejantzi3rd/e7861052c5231e2e440e95729d19bcaa to your computer and use it in GitHub Desktop.
Javascript XPath example
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
getElementByXpath("//span[contains (text(), 'Ad')]//ancestor::article").remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment