Skip to content

Instantly share code, notes, and snippets.

@NoTimeForHero
Created June 20, 2019 22:51
Show Gist options
  • Save NoTimeForHero/bb817ca29d43f83c5a194107317e5deb to your computer and use it in GitHub Desktop.
Save NoTimeForHero/bb817ca29d43f83c5a194107317e5deb to your computer and use it in GitHub Desktop.
Сниппет для получения простого селектора XPATH по аналогии с querySelectorAll
document.xpathSelectorAll = (selector) => {
const nodes = document.evaluate(selector, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
return Array(nodes.snapshotLength).fill(1).map((x, id) => nodes.snapshotItem(id));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment