Last active
October 7, 2016 10:40
-
-
Save loretoparisi/37a5be1d387908ca63d00e46b36f561e to your computer and use it in GitHub Desktop.
Wicked-Good-Xpath browser example
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
// inject Wicked-Good-Xpath | |
var script = document.createElement('script'); | |
script.src = "https://github.com/google/wicked-good-xpath/releases/download/1.3.0/wgxpath.install.js"; | |
document.getElementsByTagName('head')[0].appendChild(script); | |
script.onload=function() { | |
console.log("injected") | |
// install wgxpath | |
wgxpath.install() | |
// create expression | |
var expressionString = '//*[@class="word-and-pronunciation"]/h1'; | |
var expression = window.document.createExpression(expressionString); | |
// evaluate | |
var result = expression.evaluate(window.document,XPathResult.STRING_TYPE); | |
console.log(result.stringValue) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uglified with UglifyJS