Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shadkawa/03531f32d70227dedf4fb1c99cb19f1a to your computer and use it in GitHub Desktop.
Save shadkawa/03531f32d70227dedf4fb1c99cb19f1a to your computer and use it in GitHub Desktop.
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
var i = 0;
var adminsNum = 1;
memberSettings.forEach(function(item) {
i = i + 1;
if (i <= (adminsNum*2)) {
return;
}
item.click();
});
console.log('Getting all remove links...')
// continue with the delete flow
timer = setTimeout(openRemoveDialog, 1000);
}
/**
* This function will display the remove dialog
*/
function openRemoveDialog() {
clearTimeout(timer);
console.log('Open dialogs');
// 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, 10000);
}
/**
* 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('button.layerConfirm.uiOverlayButton'));
// Click on the remove confirm button
var i = 1;
confirmButton.forEach(function(item) {
setTimeout(function() {
item.click();
console.log('Removing users');
}, i * 1000);
i = i + 1;
});
// Reload the page after everything is finished + 7 seconds
setTimeout(function() {
window.location.reload(false);
}, (i + 7) * 1000);
}
exposeRemoveLinks();
}();
@thoughtfulcool
Copy link

Facebook stops the operation and gives a scam warning. No members removed.

@nikhil455
Copy link

This code is not working as of 25 may 2019.
it opens the dialog box which has an option to remove facebook member but it does not click on it. the page gets reloaded and nothing happens. please update it soon as possible. thanks :)

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