Tuesday, 26 February 2019

Facebook Groups Bulk Member Removal Script

I noticed a lot of facebook-groups bulk remove scripts don't work.
So I wrote one of my own (Dated: 27th Feb, 2019) I don't know for how long this script will keep working.

Note:

- This is a pretty basic script, so make sure you're the only admin in the group at the time. It might give erratic behavior if you're presented with the password confirmation dialog for removing other admins.
- The script is pretty unoptimised so brace for impact. Even though the values work for me, they may cause your browser to crash. It depends on the performance of your browser, pc and other variables.
- For the most part these crashes shouldn't cause any more damage than they already are, so feel free to mess around with the values, to match whatever works best on your computer.

Disclaimer: This code only checks the contents of the buttons it's clicking, or attributes in some cases. So be careful of where you use the code. (Members page in the groups ONLY, as recommended by me). If you screw up, or end up doing some irreversible damage, I will not be responsible for it.

Just to confirm once more, this script is for use in the developer console for desktop browsers.



function activateRemoval()
{
var c = 0;
var btns;

// Click Member-Settings buttons
btns = document.getElementsByTagName('button');

for(n=0;n<btns.length;n++)
{
if (btns[n].getAttribute('aria-label') == 'Member Settings')
{
btns[n].click();
c++;
}
}
console.log('Activated settings-menu of '+c+ ' members');

// Start after 2sec
setTimeout(
function(){
startRemoving();
},
5000
);
}

function startRemoving()
{
var c = 0;
var spans;

// Click Remove from Group buttons
spans = document.getElementsByTagName('span');

for(n=0;n<spans.length;n++)
{
if (spans[n].innerHTML == 'Remove from Group')
{
spans[n].click();
spans[n].parentNode.removeChild(spans[n]);
c++;
}
}
console.log('Started removing '+c+ ' members');

// Confirm after 25sec
setTimeout(
function(){
confirmDeletion(true);
},
10000
);
}

function confirmDeletion(flagged)
{
var c = 0;
var btns;

// Click Confirm buttons
btns = document.getElementsByTagName('button');

for(n=0;n<btns.length;n++)
{
if (btns[n].innerHTML == 'Confirm')
{
btns[n].click();
c++;
}
}
console.log('Confirmed deletion of '+c+ ' members');

// Repeat after 10sec
if(flagged == true)
{
setTimeout(
function(){
masterRoutine();
},
10000
);
}
}

function masterRoutine()
{
// Confirm all deleted firstChild
confirmDeletion(false);

// Renavigate
var links = document.getElementsByTagName('div');
for(n=0;n<links.length;n++)
{
if (links[n].getAttribute('data-key') == 'members')
{
links[n].click();
break;
}
}

// Scroll 10 times
for(n = 0; n<5; n++)
{
setTimeout(
function(){
window.scrollBy(0,1000);
},
2000+ n*1000
);

}

// Activate after 8sec
setTimeout(
function(){
activateRemoval();
},
10000
);
}

masterList();

No comments:

Post a Comment