Skip to content

Instantly share code, notes, and snippets.

@sezgi
Last active January 11, 2019 08:15
Show Gist options
  • Save sezgi/b92dfd70a8c959f760151f5a071c0400 to your computer and use it in GitHub Desktop.
Save sezgi/b92dfd70a8c959f760151f5a071c0400 to your computer and use it in GitHub Desktop.
Deletes all group members from a facebook group except yourself. Leaving the group after running this in the javascript console will delete the group. Tested on Chrome May 29, 2017. If your network is super slow, you might want to increase the timeout delay.
// removes your box from the page so you don't get removed from the group
$$('[data-name=GroupProfileGridItem]')[0].remove();
// member action dropdowns
const actions = $$('.adminActions');
// open all dropdowns so they're added to the DOM
for (var i = 0; i < actions.length; i++) {
$$('.adminActions a')[i] && $$('.adminActions a')[i].click();
}
// leave group buttons
const buttons = $$('[data-testid=leave_group]');
var i = 0;
function removeAll() {
setTimeout(function () {
// click each button
buttons[i].click();
// click confirm button with a half second delay
setTimeout(function() {
document.getElementsByClassName('layerConfirm')[0].click()
}, 500);
i++;
if (i < buttons.length) {
// each time this is called, there will be a 3 second delay
removeAll();
}
}, 3000);
}
removeAll();
@ManuelITEC
Copy link

ManuelITEC commented Jan 10, 2019

The code does work. It was used to delete a group of about 13,000 members in about 8 hours. Multiple people ran it.

  1. Make sure you edit the excludedFbIds and enter your own Facebook ID so it doesn’t delete you first. You can find it here: http://findmyfbid.com/.
  2. Edit the last line of the above.There are 2 ways to execute the program: the one above deletes group members whose first name begins with a thru m. You can change the range to something else. The other way is to remove everything between the parenthesis and the program will delete everything. i.e.: deleteAllGroupMembers.start()
  3. In Firefox, You need to go to the group you want to delete. You must be an admin.
  4. Click on Members.
  5. Open the Tools | Web Developer | Web Console.
  6. Copy/Paste the code in the JavaScript console. It could fail after a while. Reload it.

Hi @wcwilson1950, your script worked but then it failed. I've reloaded it but keep appear this error:

Uncaught TypeError: Cannot read property 'indexOf' of null
    at getFieldParm (<anonymous>:33:12)
    at queueMembersToDelete (<anonymous>:57:18)
    at deleteAll (<anonymous>:24:3)
    at Object.deleteAllGroupMembers.start (<anonymous>:16:2)
    at <anonymous>:132:23

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