Skip to content

Instantly share code, notes, and snippets.

@drewchapin
Last active March 24, 2019 02:02
Show Gist options
  • Save drewchapin/0e7eeaaa20f8c6695563bd4b121024c4 to your computer and use it in GitHub Desktop.
Save drewchapin/0e7eeaaa20f8c6695563bd4b121024c4 to your computer and use it in GitHub Desktop.
Go to a person's Facebook friends list. Scroll until all friends are loaded. Run script in Console and it will produce a log group of "Friend Name: <profile-link>"
var divs = document.getElementsByTagName("div");
var list = new Array();
for( var i = 0; i < divs.length; i++ ) {
if( divs[i].getAttribute("data-testid") == "friend_list_item") {
var friend = divs[i].getElementsByClassName("fwb")[0];
var profile = friend.getElementsByTagName("a")[0];
list.push(friend.innerText + ": " + profile.href);
}
}
console.log(list.length+" friends");
document.write(list.sort().join("<br/>"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment