Sunday, December 4, 2016

Too Many Friends Spoil TheFacebook: The (Less Painful) Way to Unfriend Multiple FB Friends

Your Facebook connections can easily grow in size to thousands, and often it is too late when you recognize that you actually know only a few dozens of them personally! If you face such a scenario and are trying to find an easy way to unfriend as many of them as possible, this post is for you.

Due to obvious reasons, FB does not offer a bulk unfriend feature (and will probably not offer one in years to come). Moreover, due to privacy concerns, many people are still afraid of using the bulk unfriend apps and scripts (though they are quite plentiful these days).

This post gives you a pretty good overview of the options available for bulk unfriending on FB. One of the easiest way you can unfriend multiple friends with least overhead (in terms of the number of clicks and page refreshes) is via the Friends page on FB mobile site. However, as of now, even this involves 2 clicks per each friend: the Friends button followed by the Unfriend list entry. With thousands of friends to go through (since you never know when a real friend would pop up inside the vast list of fakes and unknowns), this could easily put you down.

However, combining the above approach with the following script, you can cut down the process to a simple click of the Yes/No button for each friend; or, more conveniently, a press of Enter (yes) or Esc (no) keys. The script is nothing fancy; no explicit access to your FB account or anything, just plain JavaScript that manipulates the page DOM.

// run on the page https://x.facebook.com/friends/center/friends/?mff_nav=1
btns = document.querySelectorAll("button._56bt");
i = parseInt(prompt("resume from"));
for (i += (1 - i % 2); i < btns.length; i += 2) {
	btns[i].click();
	go = prompt("Unfriend " + btns[i].parentElement.parentElement.parentElement.parentElement.parentElement.children[1].children[0].children[0].textContent + "?");
	if (go != null) {
		if (go.length > 0) {
			break;
		}
		document.querySelectorAll('a[data-sigil="touchable touchable mflyout-remove-on-click m-unfriend-request"]')[0].click();
	}
	console.log(i);
}

For use, navigate to the Friend list page (https://x.facebook.com/friends/center/friends/?mff_nav=1), open the browser's web console (F12), paste the script and press Enter.

At startup, the script asks for a starting index, which can be useful if you want to stop the process and resume it at a later time. The script prints a numeric index after each confirmation, and you can simply provide the last-printed index to resume from that point. You can stop the process anytime by typing some text into the input field of the confirmation dialog and pressing OK (in which case nothing would be done to the friend currently being displayed). (Please note that this index would no longer be valid if you have reloaded the page after unfriending some friends, in which case the unfriended ones would already have been removed from the list.)

Before you run the script, make sure that you scroll down the page as far down as required (the page only loads a limited number of friend entries, and dynamically loads more friends only after you have scrolled to the bottom).

Disclaimer: The script has been tested only on Firefox browser so far. As always, use at your own risk!

1 comment:

Thanks for commenting! But if you sound spammy, I will hunt you down, kill you, and dance on your grave!