Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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();
}();
@Pankekus
Copy link

Hello, is a modification for unbanning all group members possible? Have a good day!

@kencarino
Copy link
Author

Hi @Pankekus, this script is only designed for deleting group members and is not eligible for unbanning group members. Have a great day ahead!

@KeviinCosmos
Copy link

Will it work if i go the site with inactive members? I really want to delete all my inactive members, but not all :)

@greenclouds1
Copy link

This needs to be fixed. It will delete several members, then Facebook will stop the code. Then you have to paste the code again and run it and keep doing it over and over.

@kencarino
Copy link
Author

Hi @KeviinCosmos, right now the script will delete members whether active or inactive.

@sbaa9
Copy link

sbaa9 commented Jul 12, 2018

مرحبا انا بحاجه مساعدة

@sbaa9
Copy link

sbaa9 commented Jul 12, 2018

لا اعرف كيف الاستخدلم هل يمكنك مساعدتي

@Fabian7727
Copy link

Fabian7727 commented Jul 15, 2018

Hi, I tried the skript in chrome and firefox on osx and i doesn't seem to work at all. The Java-console responds with:

VM1834:24 Getting all remove links...
undefined
VM1834:36 Open dialog

a couple seconds later the page reloads and no user is deleted. Any ideas ?

Edit -> I found the Problem: Facebook needs to be in English.

Copy link

ghost commented Jul 17, 2018

Your script is good for Opera, chrome(i have doubt) if i am right but not for Mozilla since it uses the strong webkit url expansion which messed the whole UI layout that i have tested, but sometimes its just a flash of light which turns black. so add the numeric code functions that allow user input and the code will be fine

@poohgoil
Copy link

image

Help! This was working until 2 weeks ago and now I get this error.

@poohgoil
Copy link

@kencarino, Can you help?

@Sagatt
Copy link

Sagatt commented Feb 1, 2019

Please update this.
@kencarino

@kencarino
Copy link
Author

Oops, I wasn't receiving notification about your comments. Will post here a new update. Thank you all for letting me know about the issue. Cheers!

@batto271
Copy link

@kencarino any news?

@nikhil455
Copy link

not working .. please update it. i cannot find updated code anywhere and this is urgent...thanks...

@kencarino
Copy link
Author

Hi everyone,

For all who are waiting for the update, I just had some time to update the code today due to my work.
The new update has been tested only to the Chrome browser at the moment.

Please let me know if the new update works on your end or if ever you encounter any issues.

Thank you and have a wonderful day!

@GuyEvron
Copy link

GuyEvron commented Jun 4, 2019

@kencarino
have the same chrome version as yours, scripts opens a window to confirm the first user to delete.
then it exit.
Not working for me. any ideas ? I am a second administrator in aditional to the super admin in the group (asked mr to close the group).
Any ideas ?

@crisdelcasp1098
Copy link

kencarino have the code updated?

@kencarino
Copy link
Author

kencarino commented Jun 17, 2019

@kencarino
have the same chrome version as yours, scripts opens a window to confirm the first user to delete.
then it exit.
Not working for me. any ideas ? I am a second administrator in aditional to the super admin in the group (asked mr to close the group).
Any ideas ?

Hi @TheGreatGigi, is there any error message showing in the console where you pasted the code? If so, can share it here, the error message will help me identify the issue to fix. Thank you

@kencarino
Copy link
Author

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!

@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