Skip to content

Instantly share code, notes, and snippets.

@sekimura
Last active November 22, 2015 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sekimura/c07c18d5676ef66247e6 to your computer and use it in GitHub Desktop.
Save sekimura/c07c18d5676ef66247e6 to your computer and use it in GitHub Desktop.
delete posts on Facebook profile page
/* After deactivating some Apps (eg Twitter, Yahoo Flickr etc), I noticed that I could not remove posts via GraphAPI
* because it would be a defferent app from the app originaly posted statuses.
* There might be a better to do it via offical APIs, but I was lazy and inspected some html class names to click
* around on my profile page and delete posts.
*
* Usage:
* 1. Go to your profile page and open Web Inspector Console (I used Google Chrome)
* 2. Copy and paste the script below to the console
* 3. Ovserve how it's deleting your posts or just open another tag to go somewhere else
*
* NOTE: Those html tag class names are based on Facebook web design Nov 22nd, 2015. You might need to modify those.
*
* MIT @sekimura
*/
// define deletePost a function delete a post on the top of your timeline
lastId = '';
deletePost = function() {
// Open Pull down menu
var uiPopover = document.getElementsByClassName('_5pbj _p')[0];
var curId = uiPopover.getAttribute('id');
if (lastId === curId) {
// Sometime it's too early and see a popup about an error
var noAvailable = document.getElementsByClassName('autofocus layerCancel _4jy0 _4jy3 _4jy1 _51sy selected _42ft');
if (noAvailable.length) {
noAvailable[0].click();
}
return;
}
lastId = curId;
uiPopover.click();
setTimeout(function() {
// Click the last one "Delete" to open confirmation popup
items = document.getElementsByClassName('_54nh');
items[items.length-1].click();
setTimeout(function() {
// Click "Delete" button on the confirmation popup
document.getElementsByClassName('_42ft _4jy0 layerConfirm uiOverlayButton _4jy3 _4jy1 selected _51sy')[0].click();
}, 200);
}, 200);
};
// Repeatedly call deletePost
intervalId = setInterval(deletePost, 500);
// If something wrong happen, clear the interval (or reload your profile page)
// clearInterval(intervalId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment