Skip to content

Instantly share code, notes, and snippets.

@mntmn
Created August 7, 2017 08:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mntmn/acfb78c88593cca5a2ae89139bb1113f to your computer and use it in GitHub Desktop.
Save mntmn/acfb78c88593cca5a2ae89139bb1113f to your computer and use it in GitHub Desktop.
Hacky script for bulk deleting FB timeline activities (posts)
// use on the page https://www.facebook.com/YOUR_USER_NAME/allactivity?privacy_source=activity_log&log_filter=cluster_11
// scroll down to as many posts you want to delete (make pencil icons visible)
// recommended to delete small batches as the process gets really slow for many deletes in parallel (UI issues)
// we do stuff in parallel because a single delete can take up to 7 seconds
// to launch, call deletePost()
var knownPencils={};
function deletePost() {
var pencils=document.querySelectorAll('[data-testid="pencil_icon_link"]');
var pencilFound=false;
for (var j=0; j<pencils.length && !pencilFound; j++) {
var pencil=pencils[j];
if (!knownPencils[pencil.id]) {
knownPencils[pencil.id]=true;
pencil.click();
pencilFound=true;
var delbtns=document.querySelectorAll('[ajaxify^="/ajax/timeline/delete"]');
for (var i=0; i<delbtns.length; i++) {
var btn=delbtns[i];
if (btn.offsetParent!=null) {
console.log("delete button:",btn);
btn.click();
setTimeout(function() {
var confirmBtns=document.querySelectorAll('.uiOverlayButton.layerConfirm');
var confirmBtn=confirmBtns[confirmBtns.length-1];
console.log("confirm button:",confirmBtn);
confirmBtn.click();
setTimeout(deletePost, 100);
},500);
}
}
}
}
}
@grovdata
Copy link

grovdata commented Aug 10, 2017

@mntmn Cool, could it be modified to delete from the activity log as well?

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