Skip to content

Instantly share code, notes, and snippets.

@tgxn tgxn/extract-bans.js
Created Oct 29, 2018

Embed
What would you like to do?
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
You can’t perform that action at this time.