Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rafa-munoz/c9ce5745105a3548fe41 to your computer and use it in GitHub Desktop.
Save rafa-munoz/c9ce5745105a3548fe41 to your computer and use it in GitHub Desktop.
Delete all facebook group members on a given page. Usage: Copy this script, open developers console (F12) in chrome (win) and paste this script. The window will reload when it's finished
/**
* This script will remove all group members displayed.
*
* @author: Nir Geier
*
* Usage:
* Load as many users as you need, then open console and paste this script in the
* console.
*
* Once the script finished executing, the page will autoreload.
*
* If looking the console doesn't give any feedback of what's happening, reload the
* page and repeat again. Take into account that it will delete one user per second,
* so it may take a while.
*/
var FBClearGroup = function() {
// Get all the Admins settings buttons
var memberSettings, removeLinks, timer;
/**
* This function will click on all the uses admin settings buttons to add the remove link to the page dom
*/
function exposeRemoveLinks() {
memberSettings = Array.prototype.slice.call(document.querySelectorAll('.adminActions [role="button"]'));
// Expose all the remove users links except the first one, which is the admin
console.debug('Getting all remove links...')
var i = 0;
memberSettings.forEach(function(item) {
i = i + 1;
if (i == 1) {
return;
}
item.click();
});
// continue with the delete flow
timer = setTimeout(openRemoveDialog, 1000);
}
/**
* This function will display the remove dialog
*/
function openRemoveDialog() {
clearTimeout(timer);
// Grab all the remove links
removeLinks = Array.prototype.slice.call(document.querySelectorAll("a[href*='remove.php']"));
removeLinks.forEach(function(item) {
item.click();
});
// Remove the users
timer = setTimeout(removeUsers, 1000);
}
/**
* This method will click on the remove user and will remove the user form group
*/
function removeUsers() {
// Grab all the confirm buttons
var confirmButton = Array.prototype.slice.call(document.querySelectorAll('.layerConfirm.uiOverlayButton[type="submit"]'));
// Verify that the previous step has completed
if (confirmButton.length + 1 < memberSettings.length) {
timer = setTimeout(removeUsers, 1000);
} else {
// Click on the remove confirm button
console.debug('Starting removing users')
var i = 1;
confirmButton.forEach(function(item) {
setTimeout(function() {
item.click();
console.debug('Removed user');
}, i * 1000);
i = i + 1;
});
// Reload the page after everything is finished + 7 seconds
setTimeout(function() {
window.location.reload(false);
}, (i + 7) * 1000);
}
}
exposeRemoveLinks();
}();
@fnk0c
Copy link

fnk0c commented Dec 31, 2015

Actually it is deleting the admins. I looked the code and, as I understand, it should add all admins to exception list. But it is not happening

@VIRUXE
Copy link

VIRUXE commented Feb 21, 2016

This script doesn't do user exceptions. It just ignores the first user in every page, that should be us. You can just add back the Admins when finished.

@alimamoon
Copy link

thanks man. it worked 👍 tried it on firefox not chrome

@staliot
Copy link

staliot commented May 5, 2016

i'm deleting a group of 25k people, that's slowly but worth

Copy link

ghost commented Jun 10, 2017

Hi, having a problem. It only seems to delete a single user?

@kerenbe4
Copy link

kerenbe4 commented Mar 10, 2018

Hi man!
Thanks a lot for this one!!
I hade to change 2 selectors, maybe due to ui changes, after that worked like a charm. Forked it up here:
https://gist.github.com/kerenbe4/a4117b2d560bd54af466f0e4991b1526

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment