Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kencarino/3be7c5ee0bec39da99a05639c0fc2673 to your computer and use it in GitHub Desktop.
Save kencarino/3be7c5ee0bec39da99a05639c0fc2673 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 script will delete all the members that you can see in the given page. Once the script is done you should see a group with no members.
/**
*
* This script will remove all group members displayed on group page except admins.
*
* @author: Nir Geier
* @modified: Ken Carino
*
* Updated May 29, 2019 - Tested on Chrome Version 74.0.3729.169
*
* Requirements:
* 1. Facebook must use english as language
*
* Usage:
* Load as many users in group members page, then open console and paste this script in the
* console. All members loaded in the page will be deleted by this code.
*
* Once the script finished executing, the page will automatically reload.
*
* 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() {
/**
* Var initialization
*/
var memberSettings, removeLinks, timer;
/**
* This will grab all remove links available on the page
*/
function grabRemoveLink() {
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();
document.querySelectorAll('a[data-testid="leave_group"]')[0].click();
});
console.log('Getting all remove links...');
// continue with the delete flow
timer = setTimeout(removeMember, 10000);
}
/**
* This function will trigger remove buttons
*/
function removeMember() {
clearTimeout(timer);
var confirmButton = Array.prototype.slice.call(document.querySelectorAll('button.layerConfirm.uiOverlayButton'));
var i = 1;
confirmButton.forEach(function(item) {
console.log(item);
setTimeout(function() {
item.click();
console.log('Removing member...');
}, i * 1000);
i = i + 1;
});
// Reload the page after everything is finished + 7 seconds
setTimeout(function() {
window.location.reload(false);
}, (i + 7) * 1000);
}
grabRemoveLink();
}();
@GuyEvron
Copy link

@kencarino

kencarino have the code updated?

@crisdelcasp1098 yes, the code has been updated. Kindly let us know if it works on your end or not. Thank you and have a good day!

now using another PC.
chrome Version 75.0.3770.90 (Official Build) (64-bit)

I am using the latest code. we are 2 administrators. I am NOT the super Admin.
Now when I run the script, It openes only one "remove" window, and deletes the first non admin user, but then it is refreshed exits .
From one hand I see it "catches 15 elements in the group , but it appears only one "remove" window is being opened.

@crisdelcasp1098
Copy link

works in opera

@crisdelcasp1098
Copy link

have a script to delete massive goup post?

@GuyEvron
Copy link

Tried it on Opera too.
Same result. It deletes the first member who is not an admin, wait 10 secs, refresh and exit, instead of deleted the next member.

@nikhil455
Copy link

It removed the admins :( not others..chrome

@michaelphillips1980
Copy link

Removes one member (not admin, which is good, since I should be the last).... THEN it returns an error message and the process stops.
Here is the error:

jquery-1.8.2.min.js:2 Cross-Origin Read Blocking (CORB) blocked cross-origin response https://api.ipify.org/?format=json with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

@crisdelcasp1098
Copy link

no longer works with any browser

@NessunoIM
Copy link

Hi, this script no longer works. It delete only the first member, then reload the page and the process stops.

@h-salem
Copy link

h-salem commented Aug 12, 2020

hello,
is it possible to change the code so, it skips the admins, moderators and the pre-approved members? for example to start deleting from member number 100 so it skips the admins and moderators and preapproved lists?
or to delete only members added on exact dates ?

thanks

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