Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Facebook friends backup in web browser
/* Facebook friends backup in web browser
* Scroll down to your friends page to load all profiles
* Copy-paste the script below in a web browser console (F12 key or Ctrl+Shift+K shortcut in a browser like Firefox) and press enter
* A textarea will appear at the end of the page so you can copy your friends list and paste it in a text file before saving it as a CSV file
* You can then view your backup in a spreadsheet editor like LibreOffice Calc
* You can also compare the backup with another one to see who removed you from their friends list (e.g. with the Linux diff command)
* If the friend changed their name or profile URL, you can still find them with their profile ID which is backed up in the last column (open in a web browser)
* The Facebook Graph API was not used because they are locking or deprecating most of their endpoints (e.g.
var list = document.getElementsByClassName("uiProfileBlockContent");
var length = list.length;
var data = [];
for (var i = 0; i < length; ++i) {
data[i] = list[i].firstElementChild.children[1].firstElementChild.firstElementChild.firstChild.nodeValue;
data[i] += "\t" + list[i].firstElementChild.children[1].firstElementChild.firstElementChild.href;
var json = JSON.parse(list[i].firstElementChild.children[1].firstElementChild.firstElementChild.getAttribute("data-gt"));
if (json) { // JSON data is null when the Facebook profile is deactivated
data[i] += "\t" + json.engagement.eng_tid; // get profile ID in case the Facebook user changes their profile URL
var box = document.createElement("textarea");
box.value = data.join("\n");

This comment has been minimized.

Copy link

hoshi411 commented Mar 21, 2020

What is a web browser console?


This comment has been minimized.

Copy link
Owner Author

baptx commented Mar 21, 2020

@hoshi411 it is a web browser area where you can execute custom JavaScript code, you can open it with the F12 key or Ctrl+Shift+K shortcut in a browser like Firefox (I just updated the script comment to mention this for people who are not familiar with it).

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.