Last active
October 17, 2023 21:51
-
-
Save DanTup/653b43079de26c249308 to your computer and use it in GitHub Desktop.
Delete all Facebook posts for a year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only tested in Chrome... | |
// Must browse to "Your Comments" (or "Your Likes") page of activity feed, then pre-load the year you want to delete | |
// and as many comments as possible (scroll down, they load lazily). | |
// | |
// I ACCEPT ABSOLUTELY NO RESPONSIBILITY FOR THIS DOING BAD STUFF. THE NEXT FACEBOOK DEPLOYMENT | |
// COULD WELL BREAK THIS, OR MAKE IT DO THINGS YOU DO NOT EXPECT. USE IT AS A STARTING POINT ONLY! | |
// | |
// It will start failing once it gets to the end, just reload the page and kick it off again. | |
var rows = document.querySelectorAll('#year_2012 .pam._5shk'); | |
for (var k = 0; k < rows.length; k++) { | |
var row = rows[k]; | |
var editButton = row.querySelector('.sp_DcMiPntlyW3.sx_042f0f'); | |
if (!editButton) { | |
console.log('DONE!'); | |
break; | |
} | |
editButton.click(); | |
var possibleDeleteLinks = document.querySelectorAll('a[ajaxify]'); | |
for (var i = 0; i < possibleDeleteLinks.length; i++) { | |
var link = possibleDeleteLinks[i]; | |
if (link.getAttribute('ajaxify').startsWith('/ajax/timeline/all_activity/remove_content.php') && link.getAttribute('ajaxify').contains(row.id)) { | |
var prev = row.querySelector('.fsm'); | |
if (prev != null) | |
console.log('DELETING (' + row.id + ') ' + prev.textContent); | |
else | |
console.log('DELETING (' + row.id + ')'); | |
link.click(); | |
break; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only tested in Chrome... | |
// Must browse to "Your Posts" page of activity feed, then pre-load the year you want to delete | |
// then paste into console and update the year in the selector. | |
// | |
// I ACCEPT ABSOLUTELY NO RESPONSIBILITY FOR THIS DOING BAD STUFF. THE NEXT FACEBOOK DEPLOYMENT | |
// COULD WELL BREAK THIS, OR MAKE IT DO THINGS YOU DO NOT EXPECT. USE IT AS A STARTING POINT ONLY! | |
// | |
// It will stop after a while, just reload the page and kick it off again. | |
setInterval(function() { | |
var row = document.querySelector('#year_2013 .pam._5shk'); | |
var editButton = row.querySelector('.sp_DcMiPntlyW3.sx_042f0f'); | |
if (!editButton) { | |
console.log('DONE!'); | |
return; | |
} | |
editButton.click(); | |
var possibleDeleteLinks = document.querySelectorAll('a[ajaxify]'); | |
for (var i = 0; i < possibleDeleteLinks.length; i++) { | |
var link = possibleDeleteLinks[i]; | |
if (link.getAttribute('ajaxify').startsWith('/ajax/timeline/delete/confirm') && link.getAttribute('ajaxify').endsWith(row.id)) { | |
var prev = row.querySelector('.fsm'); | |
console.log('DELETING (' + row.id + ') ' + prev.textContent); | |
link.click(); | |
setTimeout(function() { | |
var frms = document.querySelectorAll('form[action]'); | |
for (var j = 0; j < frms.length; j++) { | |
var frm = frms[j]; | |
if (frm.action.startsWith('https://www.facebook.com/ajax/timeline/delete?identifier=') && frm.action.endsWith(row.id)) { | |
var deleteButton = frm.querySelector('button'); | |
console.log(deleteButton.textContent); | |
deleteButton.click(); | |
row.remove(); | |
break; | |
} | |
} | |
}, 250); | |
break; | |
} | |
} | |
}, 500); |
I'm sorry I'm not pro, may I know how to use this code? where I can paste it ?
You would paste it into the developer console, but this code is quite old and it's very likely (maybe even probable) that site changes will affect it. I wouldn't recommend using it unless you fully understand what it's doing and confirm the selectors are still correct for the links you want it to click (otherwise it might click links you don't want it to).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm sorry I'm not pro, may I know how to use this code? where I can paste it ?