Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kerenbe4/a4117b2d560bd54af466f0e4991b1526 to your computer and use it in GitHub Desktop.
Save kerenbe4/a4117b2d560bd54af466f0e4991b1526 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("button[aria-label='Member Settings']"));
// Expose all the remove users links except the first one, which is the admin
console.debug('Getting all remove links...')
var i = 0;
var adminsNum = 1;
memberSettings.forEach(function(item) {
i = i + 1;
if (i <= (adminsNum*2) {
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[ajaxify*='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();
}();
Copy link

ghost commented Jul 17, 2018

You are code will not work cuz you have defined undefined token which is messing the whole the code, repeating and conjugating the process is going to work, i hope you are going to solve it.
if you need any help pm me anytime

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