Skip to content

Instantly share code, notes, and snippets.

@htdat
Created March 4, 2017 15:39
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save htdat/2e9a1229eccbf97c58cb48fbcce08384 to your computer and use it in GitHub Desktop.
Save htdat/2e9a1229eccbf97c58cb48fbcce08384 to your computer and use it in GitHub Desktop.
Delete FB group pending posts for admins
/**
* Please use this file at your own risk. I don't provide the support for it.
* Any suggestion or problem are welcomed to report here :)
*/
/**
* Usage:
* 1. Log-in as an group admin in the desktop
* 2. Go to your group pending list like: https://www.facebook.com/groups/[group-id]/pending/
* 3. Insert the following code to your browser console. See the guide: https://developer.chrome.com/devtools/docs/console
*
* Note:
* - This will delete all posts in your pending list, so please make sure you don't need them any more.
*/
var count_del = 0;
var count_confirm = 0;
var click_del = function () {
//button 'x' delete, class: img sp_WVlmwZ4PzbP sx_8019e2 | img sp_vPWoN8_ZzE7 sx_5cd324 | img sp_uBI2xAARzhd sx_812cfb | img sp_P3HKPeqx6sL sx_f56b15
var inputs_del = document.getElementsByClassName('img sp_WVlmwZ4PzbP sx_8019e2');
for(var i=0; i<inputs_del.length;i++) {
if ( i == 10) { break; };
count_del++;
console.log("Click Delete " + count_del);
inputs_del[i].click();
};
};
var click_confirm = function () {
//button 'Delete' to confirm delete this post
var inputs_confirm = document.getElementsByClassName('_42ft _4jy0 layerConfirm uiOverlayButton _4jy3 _4jy1 selected _51sy');
for(var i=0; i<inputs_confirm.length;i++) {
if ( i == 10) { break; };
count_confirm++;
inputs_confirm[i].click();
console.log("Click Confirm " + count_confirm);
};
};
var click_ok = function () {
//button 'Okay' when a post was deleted already
var inputs_confirm = document.getElementsByClassName('_42ft _4jy0 layerCancel uiOverlayButton _4jy3 _4jy1 selected _51sy');
for(var i=0; i<inputs_confirm.length;i++) {
if ( i == 10) { break; };
inputs_confirm[i].click();
console.log("Click OK ");
};
};
var interval_del = setInterval( function () { click_del() }, 8000);
var interval_confirm = setInterval( function () { click_confirm() }, 3000);
var interval_ok = setInterval( function () { click_ok() }, 8000);
//clearInterval(interval_ok);
//automatically scroll down to the bottom of page - ref: http://bit.ly/1O4tvHd
var interval_bottom_page = setInterval( function () { window.scrollTo(0,document.body.scrollHeight) }, 30000); ;
@sgsuneel
Copy link

sgsuneel commented Sep 3, 2019

It's still working with a minor edit in 22nd line

I changed the value of variable "inputs_del" to '3-8 img sp_gYK8kt9aJ39 sx_7f156d' and it works just fine.

Thanks for this script.

@skphantom
Copy link

Hey Guys,
I don't get it to work. Is it still working on your side?
Thanks for your help

@MrTrizaeron
Copy link

Hey Guys,
I don't get it to work. Is it still working on your side?
Thanks for your help

Yes, this still works. You need to actually change the value img sp_WVlmwZ4PzbP sx_8019e2 (line 22) to your own class name. Right click from the pending page, https://www.facebook.com/groups/tagbilaranbuyandsell/pending and find the class name for the "decline" button. Mine is _3-8_ img sp_ojMFfRlPQwI_1_5x sx_ab0ac8

htdat, thanks for this :)

@htdat
Copy link
Author

htdat commented Apr 16, 2020

Thanks MrTrizaeron for your kind words.

Yes, you guys may need to look up the correct class value. It seems that Facebook changes it over time.
https://developers.google.com/web/tools/chrome-devtools/inspect-styles

@skphantom
Copy link

That's cool, thank you very much Mr Trizaeron, and thank a lot Htdat for having came up with this!

What about the unactive members of group? It is also a pain in this ass to do so...Would I be able to apply the same script to it and changing the value of the class?

@skphantom
Copy link

image

@skphantom
Copy link

I shall precise that having such a thing is great cause you can inscrease you engagment rate of your group by removing the unactive/disabled account.

@skphantom
Copy link

Hello Htdat,
I am happy to give you 50 buck by principale if you can customize your script and help me delete all the inactive facebook group members.
Let me know thank you, that would be a great help!
Kind regard,
Arnaud

@htdat
Copy link
Author

htdat commented May 13, 2020

@skphantom - thanks for the offer. However, I am not able to work on it at the moment. If someone is able to do that, please help @skphantom.

@jacksparrow5
Copy link

I really created an account to say thanks a lot @htdat

It would be nice if you help us(group admins) with script to delete "all facebook group posts " or delete group posts with "searched keyword"

Once again thanks a lot buddy @htdat

@marcos635
Copy link

function deleteButtons() {
	var recusar = document.querySelectorAll('.sx_67dd83');
    	recusar.forEach(btn => btn.click());
};

function confirmdelete() {
        //button 'Delete' to confirm delete this post 
  	var excluir = document.querySelectorAll('.layerConfirm'); 
    	excluir.forEach(btn => btn.click());
};    

var interval_del = setInterval( deleteButtons, 8000);
var interval_confirm = setInterval( confirmdelete, 3000);

@jacksparrow5
Copy link

@marcos635 so wat tis script do bro?

@marcos635
Copy link

@jacksparrow5 The same thing as the htdat script, but in a simpler way.

@jacksparrow5
Copy link

@marcos635 Thanks buddy will check
is there any script to delete all "facebook group posts" with "specific keyword" search?

@skphantom
Copy link

Hey Guys,
Is there someone able to customize this script and allow blocking member while deleting the pending post?
Cheers

@volkankaban
Copy link

Abandoned.

@htdat
Copy link
Author

htdat commented Apr 26, 2021

Hi all, I have not managed a FB group for a long time.
Feel free to discuss or write links to other solutions, however, I am not able to fix or modify my original script.

@Virneto
Copy link

Virneto commented May 4, 2021

Hi all, I have not managed a FB group for a long time.
Feel free to discuss or write links to other solutions, however, I am not able to fix or modify my original script.

Hi htdat.
For some reason I can't find exactly the class for the deletion element.
FB code is getting increasingly obfuscated.

Any code that could remove all pending live videos would be of great help.

@amitdevopsschool
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment