-
-
Save nirgeier/7c3950db8f23e67b155a to your computer and use it in GitHub Desktop.
/** | |
* This script will delete all group members which are displayed in a given page. | |
* | |
* @author: Nir Geier | |
* | |
* Usage: | |
* Load as many users as you need, then open console and paste this script in teh console. | |
* Once the script finished executing you will be see blank members page, reload the next | |
* page and start the process again. | |
* | |
* !!! Important | |
* Sometimes after opening teh confirm dialog the page look "freeze" for a while | |
* Its OK and it takes time to remove all users. | |
* | |
* If the page doen not return the members list page after few minutes, refresh the page and execute the script again | |
*/ | |
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 | |
memberSettings.forEach(function(item) { | |
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']")); | |
// Verify that the previous step has completed | |
// The -1 is the number of the admins in the gorup. | |
if (removeLinks.length < memberSettings.length-1) { | |
// wait for previous step to complete | |
timer = setTimeout(openRemoveDialog, 1000); | |
} else { | |
// Open all the remove dialog | |
removeLinks.forEach(function(item) { | |
item.click(); | |
}); | |
// delete 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 < memberSettings.length) { | |
timer = setTimeout(removeUsers, 1000); | |
} else { | |
// Click on the remove confirm button | |
confirmButton.forEach(function(item) { | |
item.click(); | |
}); | |
} | |
} | |
exposeRemoveLinks(); | |
}(); |
The script opens all the 'Remove?' dialogs just fine, but it doesn't seem to be selecting the Confirm buttons. Update please?
TheMultiYoshi, I have also faced the same problems you.
Great code, but having removeUsers(){} run on timer inside a try-catch block without confirmation of completion of the previous step would actually help clean memory alongside open up new links.
otherwise it would only bloat up the web UI with confirmations till it's finally done selecting.
Your code is not working at the moment maybe because Facebook changes. I forked your code with a solution that is working for me:
https://gist.github.com/Menda/c9ce5745105a3548fe41
Above solutions doesn't work as of the moment. I forked your code to make the solution working:
https://gist.github.com/kencarino/3be7c5ee0bec39da99a05639c0fc2673
@kencarino, your solution isn't working for me anymore, either. :(
not working as of 25 may 2019. please update it. thanks :)
new script?????
??
hi, is still working? is there a way to load more than 200 members in the group?
Hello thank you for this.
Can you customize the script we can delete only the inactive facebook group members?
Cheers
Above solutions doesn't work as of the moment. I forked your code to make the solution working:
https://gist.github.com/kencarino/3be7c5ee0bec39da99a05639c0fc2673
Hello Kencarino, would you be able to adapt the code in unavailable member section of a group, all the disabled members can be deleted automatically? I would be happy to give you some money for that.
Thanks a ton for this, works perfectly!