Created
October 29, 2018 10:24
-
-
Save tgxn/a47ed83823c9bfa1f12b0e8745753a7c to your computer and use it in GitHub Desktop.
This file contains 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
var getElementByXpath = function(path) { | |
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
}; | |
var mainUserElem = getElementByXpath("//html/body/div[1]/div/div/div/div/div/div/div[2]/div[2]/div[1]/div/div[2]"); | |
var users = []; | |
for (var index in mainUserElem) { | |
if(index.indexOf('__reactEventHandlers') !== -1) { | |
var userChilds = mainUserElem[index].children; | |
for (var index2 in userChilds) { | |
var thisChild = userChilds[index2]; | |
users.push({ | |
username: thisChild.props.children.props.children.props.username, | |
timeAgo: thisChild.props.children.props.children.props.timeAgo, | |
description: thisChild.props.children.props.children.props.description | |
}); | |
} | |
} | |
} | |
console.log(JSON.stringify(users)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment