Forked from nirgeier/Delete all facebook members (all the one visible on a given page)
Last active
March 10, 2018 13:24
-
-
Save rafa-munoz/c9ce5745105a3548fe41 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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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('.adminActions [role="button"]')); | |
// Expose all the remove users links except the first one, which is the admin | |
console.debug('Getting all remove links...') | |
var i = 0; | |
memberSettings.forEach(function(item) { | |
i = i + 1; | |
if (i == 1) { | |
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[href*='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(); | |
}(); |
i'm deleting a group of 25k people, that's slowly but worth
Hi, having a problem. It only seems to delete a single user?
Hi man!
Thanks a lot for this one!!
I hade to change 2 selectors, maybe due to ui changes, after that worked like a charm. Forked it up here:
https://gist.github.com/kerenbe4/a4117b2d560bd54af466f0e4991b1526
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks man. it worked 👍 tried it on firefox not chrome