Advertisement
TrunghieuTH10

Remove All Member In Groups

Jul 20th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Facebook - Remove All Member In Groups
  2. // Trunghieuth10
  3.  
  4.  
  5. var FBClearGroup = function() {
  6.  
  7.     // Get all the Admins settings buttons
  8.     var memberSettings, removeLinks, timer;
  9.  
  10.     /**
  11.      * This function will click on all the uses admin settings buttons to add the remove link to the page dom
  12.      */
  13.     function exposeRemoveLinks() {
  14.         memberSettings = Array.prototype.slice.call(document.querySelectorAll('.adminActions [role="button"]'));
  15.  
  16.         // Expose all the remove users links except the first one, which is the admin
  17.         console.debug('Getting all remove links...')
  18.  
  19.         var i = 0;
  20.         memberSettings.forEach(function(item) {
  21.             i = i + 1;
  22.             if (i == 1) {
  23.                 return;
  24.             }
  25.             item.click();
  26.         });
  27.  
  28.         // continue with the delete flow
  29.         timer = setTimeout(openRemoveDialog, 1000);
  30.     }
  31.  
  32.     /**
  33.      * This function will display the remove dialog
  34.      */
  35.     function openRemoveDialog() {
  36.         clearTimeout(timer);
  37.  
  38.         // Grab all the remove links
  39.         removeLinks = Array.prototype.slice.call(document.querySelectorAll("a[href*='remove.php']"));
  40.         removeLinks.forEach(function(item) {
  41.             item.click();
  42.         });
  43.  
  44.         // Remove the users
  45.         timer = setTimeout(removeUsers, 1000);
  46.     }
  47.  
  48.     /**
  49.      * This method will click on the remove user and will remove the user form group
  50.      */
  51.     function removeUsers() {
  52.         // Grab all the confirm buttons
  53.         var confirmButton = Array.prototype.slice.call(document.querySelectorAll('.layerConfirm.uiOverlayButton[type="submit"]'));
  54.  
  55.         // Verify that the previous step has completed
  56.         if (confirmButton.length + 1 < memberSettings.length) {
  57.             timer = setTimeout(removeUsers, 1000);
  58.         } else {
  59.             // Click on the remove confirm button
  60.             console.debug('Starting removing users')
  61.             var i = 1;
  62.             confirmButton.forEach(function(item) {
  63.                 setTimeout(function() {
  64.                     item.click();
  65.                     console.debug('Removed user');
  66.                 }, i * 1000);
  67.                 i = i + 1;
  68.             });
  69.            
  70.             // Reload the page after everything is finished + 7 seconds
  71.             setTimeout(function() {
  72.                 window.location.reload(false);
  73.             }, (i + 7) * 1000);
  74.         }
  75.     }
  76.  
  77.     exposeRemoveLinks();
  78. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement