Created
August 28, 2020 07:07
-
-
Save ZoolWay/1c3b18530614b8537515cfeb0f93aacb to your computer and use it in GitHub Desktop.
Tampermonkey, XPath parser function for javascript console
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
// ==UserScript== | |
// @name ricky_xpath | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://*/* | |
// @match http://*/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.ricky_xpath = function (xpath) { | |
const result = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null); | |
let nodes = []; | |
let node = result.iterateNext(); | |
while (node) { | |
nodes.push(node); | |
node = result.iterateNext(); | |
} | |
return nodes; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment