Skip to content

Instantly share code, notes, and snippets.

@tgxn
Created October 29, 2018 10:24
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 tgxn/a47ed83823c9bfa1f12b0e8745753a7c to your computer and use it in GitHub Desktop.
Save tgxn/a47ed83823c9bfa1f12b0e8745753a7c to your computer and use it in GitHub Desktop.
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