Quickly deleting users from a Facebook group

(This is old. It probably doesn’t work on Facebook anymore.)

Facebook unfortunately requires one to first individually delete users from a group before one can effectively delete the group. If you have thousands of users, this is a pain. You can use the following bookmarklet (I’ve only tested it in Google Chrome) to quickly delete about 100 users. Unfortunately, WordPress.com does not allow me to have drag-and-drop bookmarklet links in my post, so you’ll have to follow these directions:

  1. Copy the text from here.
  2. Create a new bookmark in Google Chrome and paste the text into the URL.
  3. Go to the admin page that lists users from your Facebook group and click the bookmarklet.
  4. When you are directed to the next page of users, click it again.
  5. To speed up the process even more, use multiple tabs on different pages.

For those interested, here is the code (I minified it using YUI Compressor for the bookmarklet):

function confirmDeleteUser() {
	confirmButton = document.querySelector('.uiButton.uiButtonLarge.uiButtonConfirm input');
	if(!confirmButton) {
		setTimeout('deleteAllUsersInGroup()',200);
		return;
	}
	mouseClickEvent = document.createEvent('MouseEvent');
	mouseClickEvent.initMouseEvent('click',true,true);
	confirmButton.dispatchEvent(mouseClickEvent);
	setTimeout('deleteAllUsersInGroup()',200);
}

function switchPage() {
	pageButton = document.querySelector('.next.uiButton:not(.uiButtonDisabled)');
	if(!pageButton) {
		pageButton = document.querySelector('.prev.uiButton:not(.uiButtonDisabled)');
	}
	if(!pageButton) {
		return
	}
	mouseClickEvent = document.createEvent('MouseEvent');
	mouseClickEvent.initMouseEvent('click',true,true);
	pageButton.dispatchEvent(mouseClickEvent);
}

function deleteAllUsersInGroup() {
	/* I pick a random user to account for some quirks in the process */
	deleteButtons = document.querySelectorAll('a.UIImageBlock_Ext.uiCloseButton.uiCloseButtonSmall');
	if(!deleteButtons.length) {
		setTimeout('confirmDeleteUser()',500); /* Usually one last dialog to clear */
		setTimeout('switchPage()',1500);
		return;
	}
	deleteButton = deleteButtons.item(Math.floor(Math.random() * deleteButtons.length))
	mouseClickEvent = document.createEvent('MouseEvent');
	mouseClickEvent.initMouseEvent('click',true,true);
	deleteButton.dispatchEvent(mouseClickEvent);
	deleteButton.parentNode.parentNode.removeChild(deleteButton.parentNode)
	setTimeout('confirmDeleteUser()',200);
};
deleteAllUsersInGroup();
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s