Last active
February 22, 2023 10:52
-
-
Save maci1011/30100bc2704f2ae40d3cff93144046ae to your computer and use it in GitHub Desktop.
Facebook js script for removing all group members
This file contains hidden or 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
// 1 - Go in the group members page and load 200/300 members | |
// 2 - Paste this in the console and wait | |
// 3 - Reload the page and do it again | |
var FBGMR = (function() { | |
var FBGroupMembersRemover = {}, | |
_id; | |
var fbIds = ['12345', '67890'], // Put here the ids to jump | |
menuButtons = [], | |
links = [], | |
links_index = 0, | |
menus_index = 0, | |
removed_index = 0, | |
skipped_dialogs = 0, | |
skipped_buttons = 0, | |
dialogs_windows = 10, | |
retry_number = 4, | |
loaded_menus = 30, | |
removingLasts = false, | |
play = false, | |
tried = 0, | |
i = 0; | |
function _guid() { | |
function s4() { | |
return Math.floor((1 + Math.random()) * 0x10000) | |
.toString(16) | |
.substring(1); | |
} | |
return s4() + s4() + s4() + s4() + s4() + s4() + s4() + s4(); | |
} | |
function checkFBIds(item) { | |
if (item.getAttribute('href') == null) return true; | |
fbIds.forEach(function(id) { | |
if (item.getAttribute('href').indexOf(id) != -1) return true; | |
}); | |
return false; | |
} | |
function getConfirmButtons() { | |
var confirmButtons = Array.prototype.slice.call(document.querySelectorAll('.layerConfirm.uiOverlayButton[type="submit"]')); | |
confirmButtons = confirmButtons.filter(function(el) { | |
return (el.getAttribute('fbgmremover-clicked') != 'clicked'); | |
}); | |
return confirmButtons; | |
} | |
function removeItem(item) { | |
if (item.getAttribute('fbgmremover-clicked') != 'clicked') { | |
item.setAttribute('fbgmremover-clicked', 'clicked'); | |
item.click(); | |
removed_index++; | |
console.debug('Removed Users: ' + removed_index); | |
} | |
} | |
function removeLasts() { | |
if (removingLasts) { | |
return; | |
} | |
console.debug('Start Removing Lasts'); | |
removingLasts = true; | |
removeLastsLoop(); | |
} | |
function removeLastsLoop() { | |
var confirmButtons = getConfirmButtons(); | |
var min = play ? dialogs_windows : 0; | |
if (confirmButtons.length <= min) { | |
console.debug('End Removing Lasts'); | |
// console.debug('No More Confirm Buttons.'); | |
removingLasts = false; | |
return; | |
} | |
removeItem(confirmButtons[0]); | |
setTimeout(function() { | |
removeLastsLoop(); | |
}, 1000); | |
} | |
function removeUsers() { | |
if (!play) { | |
removeLasts(); | |
return; | |
} | |
loadMenus(); | |
if (!(links_index < menuButtons.length)) { | |
play = false; | |
removeLasts(); | |
console.debug('End Removing Users'); | |
FBGroupMembersRemover.debug(); | |
return; | |
} | |
openConfirmDialogs(); | |
setTimeout(function() { | |
var confirmButtons = getConfirmButtons(); | |
if (confirmButtons.length == 0) { | |
if (tried < retry_number) { | |
tried++; | |
removeUsers(); | |
} else if (i < menuButtons.length) { | |
console.debug('Tring with the next!'); | |
tried = 0; | |
i++; | |
removeUsers(); | |
} else { | |
console.debug('Zero confirmButtons!'); | |
} | |
return; | |
} | |
tried = 0; | |
removeItem(confirmButtons[0]); | |
i++; | |
removeUsers(); | |
if (2 * dialogs_windows < confirmButtons.length) { | |
removeLasts(); | |
} | |
}, 2000); | |
} | |
function openConfirmDialogs() { | |
var len = links.length; | |
links = Array.prototype.slice.call(document.querySelectorAll('a._54nc[href*="remove.php"]')); | |
if (links.length == 0) { | |
console.debug('Zero links!'); | |
return; | |
} | |
var max = i + dialogs_windows; | |
max = max < links.length ? max : links.length; | |
var diff = max - links_index; | |
if (links_index < links.length && dialogs_windows - 1 < diff) { | |
console.debug('Opening Confirm Dialogs from ' + links_index + ' to ' + max); | |
for (var j = links_index; j < max ; j++) { | |
var item = links[j]; | |
if (item.getAttribute('fbgmremover-id') == _id) { | |
continue; | |
} | |
console.debug(checkFBIds(item)); | |
if (checkFBIds(item)) { | |
console.debug('Skipped link: ' + j); | |
// console.debug(item); | |
skipped_dialogs++; | |
continue; | |
} | |
item.setAttribute('fbgmremover-id',_id); | |
// console.debug('Loaded link: ' + j); | |
// console.debug(item); | |
item.click(); | |
} | |
links_index = max; | |
} | |
} | |
function loadMenus() { | |
var len = menuButtons.length; | |
menuButtons = Array.prototype.slice.call(document.querySelectorAll('button[data-testid*="admin_action_menu_button"]')); | |
if (menuButtons.length == 0) { | |
console.debug('Zero menuButtons!'); | |
FBGMR.debug(); | |
return; | |
} | |
var max = i + loaded_menus; | |
max = max < menuButtons.length ? max : menuButtons.length; | |
var diff = max - menus_index; | |
if (menus_index < menuButtons.length && loaded_menus - 1 < diff) { | |
FBGroupMembersRemover.debug(); | |
console.debug('Loading menuButtons from ' + menus_index + ' to ' + max); | |
for (var j = menus_index; j < max; j++) { | |
var item = menuButtons[j]; | |
// if (true) { | |
// console.debug('Skipped menuButtons Index: ' + j); | |
// console.debug(item); | |
// skipped_buttons++; | |
// continue; | |
//} | |
//console.debug('click!'); | |
item.click(); | |
} | |
menus_index = max; | |
} | |
} | |
FBGroupMembersRemover.start = function() { | |
if (play) { | |
return; | |
} | |
play = true; | |
setTimeout(function() { | |
console.debug('Start Removing Users'); | |
removeUsers(); | |
}, 500); | |
return true; | |
} | |
FBGroupMembersRemover.stop = function () { | |
console.debug('Stopped!'); | |
play = false; | |
removeLasts(); | |
return true; | |
} | |
FBGroupMembersRemover.debug = function() { | |
var dbg; | |
console.debug('Length of menuButtons: ' + menuButtons.length); | |
console.debug('Length of links: ' + links.length); | |
dbg = Array.prototype.slice.call(document.querySelectorAll('button[data-testid*="admin_action_menu_button"]')); | |
console.debug('Current Length of menuButtons: ' + dbg.length); | |
dbg = Array.prototype.slice.call(document.querySelectorAll('a._54nc[href*="remove.php"]')); | |
console.debug('Current Length of links: ' + dbg.length); | |
dbg = getConfirmButtons(); | |
console.debug('Current Length of confirmButtons: ' + dbg.length); | |
console.debug('Is Playing: ' + play); | |
console.debug('Is Removing Lasts: ' + removingLasts); | |
console.debug('Skipped Dialogs: ' + skipped_dialogs); | |
console.debug('Skipped Buttons: ' + skipped_buttons); | |
console.debug('Tried: ' + tried); | |
console.debug('Links Index: ' + links_index); | |
console.debug('Index: ' + i); | |
return true; | |
} | |
_id = _guid(); | |
return FBGroupMembersRemover; | |
})(); | |
FBGMR.start(); | |
// FBGMR.debug(); | |
// FBGMR.stop(); | |
WHY WE ARE
Uncaught SyntaxError: Unexpected token continue
Looked in the code and there's a "continue" in a function. No loop to "continue".
Remember to correctly comment out line 220.
Just corrected the line 220
...I used it in firefox, don't tested in other browsers
Will this also remove admins? (I don’t want it to remove me and 2 other people.)
I am getting what appears to be an error message (and no members are being deleted): (this is in Firefox, does not seem to do anything in Chrome)
Start Removing Users debugger eval code:239:10
Zero links!
debugger eval code:162:10
Tring with the next! debugger eval code:130:12
Zero links!
"Put here the ids to jump"
What??????
I would imagine not. Must have made this 4 years ago. If you make one that does, link it here.
…On Wed, Feb 22, 2023, at 06:41, mikez2333 wrote:
***@***.**** commented on this gist.
This doesn't work.
—
Reply to this email directly, view it on GitHub <https://gist.github.com/30100bc2704f2ae40d3cff93144046ae#gistcomment-4479077> or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAU7RHUB3P5ZOY67SOGSJVTWYWRH5BFKMF2HI4TJMJ2XIZLTSKBKK5TBNR2WLJDHNFZXJJDOMFWWLK3UNBZGKYLEL52HS4DFQKSXMYLMOVS2I5DSOVS2I3TBNVS3W5DIOJSWCZC7OBQXE5DJMNUXAYLOORPWCY3UNF3GS5DZVRZXKYTKMVRXIX3UPFYGLK2HNFZXIQ3PNVWWK3TUUZ2G64DJMNZZDAVEOR4XAZNEM5UXG5FFOZQWY5LFVA4DINJUGI4DQN5HORZGSZ3HMVZKMY3SMVQXIZI>.
You are receiving this email because you commented on the thread.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alla riga 220 ti è partita una "((" invece di "//"
Comunque a me (chrome) non funziona molto bene, se clicco manualmente sui "..." vicino all'utente e faccio "Rimuovi dal gruppo" lo script fa automaticamente la conferma, però per l'appunto devo manualmente cliccare io sui pallini e fare il "rimuovi", non lo fa da solo. A te funziona?