Skip to content

Instantly share code, notes, and snippets.

@af-inet
Created December 27, 2018 09:50
Show Gist options
  • Save af-inet/fc287e6e23e8e33dfef0c160fcb10ec8 to your computer and use it in GitHub Desktop.
Save af-inet/fc287e6e23e8e33dfef0c160fcb10ec8 to your computer and use it in GitHub Desktop.
delete all your facebook posts
/*
HOW TO USE THIS PROGRAM
1. Log in to facebook, and go to your "Activity Feed".
2. Scroll down a little bit so you have posts on the screen.
3. Paste this code into the developer console.
4. Execute deletePost() in the console.
5. Done; watch as the bot will delete roughly 1 post every 4 seconds.
6. Refresh the page to disable the script.
*/
function clickConfirmDeleteButton() {
var confirmDeleteButton = findConfirmDeleteButton();
// show the user we're about to click this button
confirmDeleteButton.style.border = "solid 2px red"
setTimeout(function () {
// finally we can delete this post
confirmDeleteButton.click();
// wait for the post to disappear
setTimeout(function () {
// the post was deleted, no need to increment the skip counter
deletePost()
}, 4000)
}, 100)
}
function findConfirmDeleteButton() {
var elements = document.querySelectorAll('button[type="submit"]');
for (var i = 0; i < elements.length; i++) {
if (elements[i].textContent.toLowerCase() === "delete") {
return elements[i];
}
}
throw new Error("failed to find confirm delete button")
}
function findDeleteButton() {
var elements = []
var iterator = document.evaluate("//a[contains(., 'Delete')]", document, null, XPathResult.ANY_TYPE, null);
var element = null;
while (element = iterator.iterateNext()) {
elements.push(element)
}
if (elements.length <= 0) {
throw new Error("did not find delete button")
}
return elements[elements.length - 1]
}
function clickDeleteButton() {
var deleteButton = findDeleteButton()
// show the user we're about to click this button
deleteButton.style.border = "solid 2px red"
setTimeout(function () {
deleteButton.click()
setTimeout(clickConfirmDeleteButton, 1000);
}, 100)
}
function findNextPost() {
var elements = document.querySelectorAll('[data-tooltip-content="Edit"], [data-tooltip-content="Allowed on timeline"], [data-tooltip-content="Hidden from timeline"]');
if (elements.length > 0) {
return elements[0];
}
return null;
}
function deletePost() {
var target = findNextPost()
if (target) {
// show the user we're about to click this button
target.style.border = "solid 2px red";
setTimeout(function () {
target.click();
// don't click that shit again
target.parentElement.removeChild(target);
setTimeout(clickDeleteButton, 100);
}, 100)
}
else {
console.log("failed to find a post, scrolling down and starting over. We might have run out of posts...");
// this part is annoying because we need to scroll down and wait for new posts to load,
// so we scroll, wait, scroll, wait, etc...
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight);
setTimeout(function () {
deletePost()
}, 1000)
}, 1000);
}, 1000);
}, 1000);
}, 1000);
}
}
@mastercodeon31415
Copy link

So today a friend of mine asked me to make a script for him that does something similar to this. However my script is current with facebooks UI and deletes much more than this script did. I may or may not be releasing this yet, I'm not sure, but anyone who wants this sort of thing done to their account, feel free to contact me!

@af-inet
Copy link
Author

af-inet commented Sep 23, 2025

So today a friend of mine asked me to make a script for him that does something similar to this. However my script is current with facebooks UI and deletes much more than this script did. I may or may not be releasing this yet, I'm not sure, but anyone who wants this sort of thing done to their account, feel free to contact me!

I imagine my script doesn't work anymore since it's been 7 years. Since you've written a better one, why not upload it to GitHub?

@mastercodeon31415
Copy link

Well I'm currently trying to find ways to monitize the things I develop. Since my friend who put me on this informed me that similar things exist for this kind of task and that they are pay for options, I'm thinking about creating a software as a service system for this script and it's operations. There are some major technical hurdles to face with that, and I'm not sure if there is a substantial enough market for this that it would validate all the work it would take to build a secure system to give a paying user access to this script. I've done some research and it does seem possible on the technical side, but I am not sure that the work would pay off since I cant find much at all of people wanting something like this. So once again, I'm not sure if the market exists for this type of service.
I'm going to be performing some research into this and seeing if people would actually want something like this and would pay for it.
If it turns out that there's not really a market for it, I'll open source this and put it on GitHub.
I'm just at a point where I'm throwing stuff at the proverbial wall and seeing what sticks in the sense of trying to monitize the work I do to make ends meet.

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