Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Facebook Posts Deleter 2018" script is a User Script to automatically delete Facebook posts one by one without any user intervention. Install this script in Firefox-based browsers (Firefox, Seamonkey, IceWeasel) using the Greasemonkey add-on. Then, go to your Facebook "Activity Log". This scripts was tested in Firefox 34. If you use a much diff…
// ==UserScript==
// @name Facebook Posts Deleter
// @namespace com.vsubhash.js.facebook-posts-deleter
// @description Deletes all facebook posts, one by one if browser is spoofed as Firefox 34
// @include https://www.facebook.com/*allactivity
// @exclude %exclude%
// @version 2018
// @grant none
// ==/UserScript==
/*
* "Facebook Posts Deleter 2018" script is a User Script to automatically delete Facebook posts one by one without any user intervention. Install this script in Firefox-based browsers (Firefox, Seamonkey, IceWeasel) using the Greasemonkey add-on. Then, go to your Facebook "Activity Log". This scripts was tested in Firefox 34. If you use a much different browser, it may not work as Facebook serves different web pages (CSS/JS) for different versions of browsers. To fix that, spoof your current browser as Firefox 34. For this, use a browser ID spoofer add-on (such as User Agent Overrider https://addons.mozilla.org/en-US/firefox/addon/user-agent-overrider/) and with the custom agent string "Mozilla/5.0 (X11; rv:34.0) Gecko/20100101 Firefox/34.0". This script was simplified and tested in 2018 and it works fine.
*/
document.addEventListener("DOMContentLoaded", startItDelayed, false);
function startItDelayed() {
window.setTimeout(clickTheMenu, 10*1000);
}
function clickTheMenu() {
console.log("FPD: Finding the menu");
arAnchors = document.getElementsByTagName("a");
for (var i = 0; i < arAnchors.length; i++) {
if (arAnchors[i].id.indexOf("u_jsonp") > -1) {
console.log("FPD: Found a menu");
arAnchors[i].click();
console.log("FPD: Clicked the menu");
window.setTimeout(clickDeleteOption, 3*1000);
break;
}
}
}
function clickDeleteOption() {
console.log("FPD: Finding the Delete option");
arAnchors = document.getElementsByTagName("a");
for (var i = 0; i < arAnchors.length; i++) {
if (arAnchors[i].hasAttribute("ajaxify")) {
if (arAnchors[i].getAttribute("ajaxify").indexOf("/ajax/timeline/delete/confirm") > -1) {
console.log("FPD: Found the Delete option");
arAnchors[i].click();
console.log("FPD: Clicked the delete option");
window.setTimeout(clickDeleteConfirmButton, 3*1000);
break;
}
}
}
}
function clickDeleteConfirmButton() {
console.log("FPD: Finding the Delete confirmation button");
arButtons = document.getElementsByTagName("button");
for (var i = 0; i < arButtons.length; i++) {
if ((arButtons[i].className.indexOf("layerConfirm") > -1) &&
(arButtons[i].textContent.indexOf("Delete") > -1)) {
console.log("FPD: Found the Delete confirm button");
arButtons[i].click();
console.log("FPD: Clicked the Delete confirm button");
window.setTimeout(function() { location.reload(true); }, 3*1000);
break;
}
}
}
@rolandh

This comment has been minimized.

Copy link

rolandh commented Apr 4, 2017

Looks like half the script is missing?

@fmmarzoa

This comment has been minimized.

Copy link

fmmarzoa commented Oct 5, 2017

No "Delete Facebook Posts" that pops on the top-left for me

Got that button using https://www.facebook.com/*allactivity as included pages instead of https://www.facebook.com/*=allactivity, but when I click it the only thing it does is to show a button for the first shown activity that I must click manually for confirming the action.

In short, it does not work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.