ngocminhta

LDDH

Jun 11th, 2021
609
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * This script will delete or remove all group members which are displayed in a given page or facebook group.
  3.  *
  4.  * @author: Nir Geier
  5.  *
  6.  * Usage:
  7.  *    Load as many users as you need, then open console and paste this script in browser (google chrome) console.
  8.  *    Once the script finished executing you will be see blank members page, reload the next
  9.  *    page and start the process again.
  10.  *
  11.  *    !!! Important !!!
  12.  *    Sometimes after opening browser (google chrome) confirm dialog the page look "freeze" for a while
  13.  *    Its OK and it takes time to remove all users. You don't need to do anythings. Just wait and see.
  14.  *
  15.  *    If the page doen not return the members list page after few minutes, refresh the page and execute the script again
  16.  */
  17. var FBClearGroup = function() {
  18.  
  19.     // Get all the Admins settings buttons
  20.     var memberSettings, removeLinks, timer;
  21.  
  22.     /**
  23.      * This function will click on all the uses admin settings buttons to add the remove link to the page dom
  24.      */
  25.     function exposeRemoveLinks() {
  26.  
  27.         memberSettings = Array.prototype.slice.call(document.querySelectorAll('.adminActions [role="button"]'));
  28.         // Expose all the remove users links
  29.         memberSettings.forEach(function(item) {
  30.             item.click();
  31.         });
  32.  
  33.         // continue with the delete flow
  34.         timer = setTimeout(openRemoveDialog, 1000);
  35.     }
  36.  
  37.     /**
  38.      * This function will display the remove dialog
  39.      */
  40.     function openRemoveDialog() {
  41.         clearTimeout(timer);
  42.  
  43.         // Grab all the remove links
  44.         removeLinks = Array.prototype.slice.call(document.querySelectorAll("a[href*='remove.php']"));
  45.  
  46.         // Verify that the previous step has completed
  47.         // The -1 is the number of the admins in the gorup.
  48.         if (removeLinks.length < memberSettings.length-1) {
  49.  
  50.             // wait for previous step to complete
  51.             timer = setTimeout(openRemoveDialog, 1000);
  52.         } else {
  53.  
  54.             // Open all the remove dialog
  55.             removeLinks.forEach(function(item) {
  56.                 item.click();
  57.             });
  58.  
  59.             // delete the users
  60.             timer = setTimeout(removeUsers, 1000);
  61.         }
  62.     }
  63.  
  64.     /**
  65.      * This method will click on the remove user and will remove the user form group
  66.      */
  67.     function removeUsers() {
  68.  
  69.         // Grab all the confirm buttons
  70.         var confirmButton = Array.prototype.slice.call(document.querySelectorAll('.layerConfirm.uiOverlayButton[type="submit"]'));
  71.  
  72.         // Verify that the previous step has completed
  73.         if (confirmButton.length < memberSettings.length) {
  74.             timer = setTimeout(removeUsers, 1000);
  75.         } else {
  76.  
  77.             // Click on the remove confirm button
  78.             confirmButton.forEach(function(item) {
  79.                 item.click();
  80.             });
  81.         }
  82.     }
  83.  
  84.     exposeRemoveLinks();
  85.  
  86. }();
  87.  
RAW Paste Data