Last active
June 27, 2020 16:52
-
-
Save joshm21/76cdf4983699e7bc495f8dbe63340b81 to your computer and use it in GitHub Desktop.
Parse profile id, vanity, and name from Facebook friends page. Make sure you scroll to bottom first!
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
function parse() { | |
let people = document.querySelectorAll("._5qo4"); | |
for (let i = 0; i < people.length; i++) { | |
const aElement = people[i].querySelector("a._5q6s"); | |
let id = null; | |
let vanity = null; | |
if (aElement != null) { | |
const hovercardLink = aElement.getAttribute("data-hovercard"); | |
const idRegex = new RegExp("^/ajax/hovercard/user.php\\?id=(\\d{1,})&.{1,}", "g"); | |
id = idRegex.exec(hovercardLink)[1]; | |
const profileLink = aElement.href; | |
const vanityRegex = new RegExp("^https://www.facebook.com/(.{1,}?)\\?.{1,}", "g"); | |
vanity = vanityRegex.exec(profileLink)[1]; | |
} | |
const imgElement = people[i].querySelector("img"); | |
const name = imgElement.getAttribute("aria-label"); | |
console.log(`${id},${vanity},${name}`); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment