Skip to content

Instantly share code, notes, and snippets.

@scazzy
Created November 14, 2018 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scazzy/4fc82f2a15550d0ddb471f537e11ad16 to your computer and use it in GitHub Desktop.
Save scazzy/4fc82f2a15550d0ddb471f537e11ad16 to your computer and use it in GitHub Desktop.
Javascript code to delete all pending posts from Facebook group lazily/infinitely
/*
* Function to infinitely delete pending posts from a facebook group
* Execute this code in console on the facebook group page > pending posts
*/
function deletePosts () {
var deleteButtons = document.querySelectorAll('a[role=button][ajaxify*=delete]')
deleteButtons.forEach( b => {
b.click()
})
if(!deleteButtons.length) return;
var confirmButtons = document.querySelectorAll('button[data-testid=delete_post_confirm_button]')
setTimeout(() => {
confirmButtons.forEach( d => {
d.click()
})
window.scrollTo(0, document.body.scrollHeight);
setTimeout(() => {
if(!confirmButtons.length) return;
delposts()
}, 10000)
}, 10000)
}
deletePosts();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment