-
-
Save mohankumar-i2i/643c1c0a97f23c992a6f85ffa5b54ab4 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment