Skip to content

Instantly share code, notes, and snippets.

@techanon
Last active December 18, 2018 23:04
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 techanon/ac062c9424eb9ab193684408491a7884 to your computer and use it in GitHub Desktop.
Save techanon/ac062c9424eb9ab193684408491a7884 to your computer and use it in GitHub Desktop.
function getElementsByXpath(path, context) {
if (!context) context = document;
let res = document.evaluate(path, context, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
let tmp, out = [];
while (tmp = res.iterateNext())
out.push(tmp);
return out;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment