Skip to content

Instantly share code, notes, and snippets.

@guessi
Created February 22, 2025 08:36
Show Gist options
  • Save guessi/21be70b9c031a0ff5d17fc2b481b323f to your computer and use it in GitHub Desktop.
Save guessi/21be70b9c031a0ff5d17fc2b481b323f to your computer and use it in GitHub Desktop.
Retrieve Facebook friends list with your browser
// How to use this script?
//
// 1. Go to your profile page
// 2. Go to "Friend" tab
// 3. Keep scrolling down, until all friends data loaded
// 4. Open browser's "Console" (short cut on macOS: Cmd + F12)
// 5. Execute the script below
//
// Last Modified: Feb 22, 2025
//
// Selector targeting "Display Name" of friend list (the "selector" here might broken if Facebook changes its design)
const selector = "div.xyamay9 > div.x78zum5 > div.x6s0dn4 > div:nth-child(2) > div:nth-child(1) > a:nth-child(1) > span:nth-child(1)";
// Retrieve frined list from the items selected
[...document.querySelectorAll(selector)].map(({innerHTML}) => innerHTML).sort(); // Feel free to remove `.sort()` at the end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment