Delete all the (Facebook) things!

I, like many before me, have sought to delete many a post from my Facebook Timeline but have faced challenges that would strike fear into the hearts of better men than I. Alas after trying (and failing) every remedy under the sun, I wrestled the recalcitrant beast myself.

The horrid code below is my solution that has served me very well. It’s pretty reprehensible stuff but it ultimately works similarly to my Tumblr Queue Shuffler. You copy it into Developer Tools or Firefox Developer Tools (or similar, try F12) and it begins by finding all Options for this story and Allowed on timeline links (for different types of content) then it continues the arduous journey by simulating a click then it waits…

After one-second (a reasonable guesstimate) the Options menu will, or rather should, be visible and it now seeks out a Remove, Unlike or Unvote link (in the menu) and simulates a click, then it waits…

After another second it seeks out either a Delete, Unlike, or Unvote button and (again) simulates a click, although this time if it fails to find any of those links it will instead click the Cancel link, before waiting…

After yet-another-second it starts again and clicks the next Options for this story or Allowed on timeline link. It is utterly indiscriminate and will remove everything it can get it’s hands on. I shouldn’t need to say this but use with caution, you use this at your own peril and I give you no guaranties, none, zero, zilch, nada, zip, not even one.

var to;

function del(ayes) {
	console.log('Posts remaining', ayes.length);

	to = setTimeout(function () {
		var a = document.querySelector('.uiLayer:not(.hidden_elem) a[ajaxify^="/ajax/timeline/take_action_on_story.php"][ajaxify*="action=remove_content"], .uiLayer:not(.hidden_elem) a[ajaxify^="/ajax/timeline/take_action_on_story.php"][ajaxify*="action=unlike"], .uiLayer:not(.hidden_elem) a[ajaxify^="/ajax/timeline/take_action_on_story.php"][ajaxify*="action=unvote"]');
		a &&;

		to = setTimeout(function () {
			var btn = document.querySelector('input[value="Delete"][name="ok"][type="button"], input[value="Unlike"][name="ok"][type="button"], input[value="Delete photo"][name="ok"][type="button"], input[value="Unvote"][name="ok"][type="button"], a.layerCancel[action="cancel"]');
			btn &&;

			if (ayes.length) {
				to = setTimeout(del.bind(null, ayes), 1000);
		}, 1000);
	}, 1000);

	return ayes.length;

del('[aria-label="Options for this story"], [aria-label="Allowed on timeline"]')));

If for whatever reason you need to stop the deletion process you can use the following snippet: to && clearTimeout(to).