Facebook Wall: Clear everything

16 May 2011
Facebook Wall: Clear everything - Remove ALL Activity

I had a problem to solve, clear my entire Facebook wall. By "clear" I mean to delete everything, status updates, links, events, photos, videos and their comments. The Facebook GUI does not provide such a function. I had to delete my facebook account -which I didn’t want to- or delete every single wall post manually one by one.

I then remembered my novice Perl skills. I had spare time, therefore I booted my Debian, I wrote a Perl script and voila! My Facebook wall was reborn.

After googling around I found two more solid solutions, a Perl one and a Greasemonkey one. Greasemonkey is a Firefox extension that allows you to customize the way webpages look and function using javascript.

 

The Perl solution:

#!/usr/bin/perl
use WWW::Mechanize;
use HTTP::Cookies;
use HTML::Parser;
use HTML::TagParser;
my $username = “EMAIL”;
my $password = “PASSWORD”;
my $mech = WWW::Mechanize->new();
$mech->agent_alias(‘Linux Mozilla’);
$mech->cookie_jar( HTTP::Cookies->new() );
$mech->post(
“https://login.facebook.com/login.php?m&next=http://m.facebook.com/minifeed.php”,
{ email => $username, pass => $password }
);
my $test = $mech->content();
$mech->content() =~ /url=(.*?)”/;
my $newurl = $1;
$mech->get($newurl);
my $html = $mech->content();
my $parser = HTML::Parser->new(
api_version => 3,
start_h => [ &start, "tagname, attr" ],
);
my @links;

sub start {
my ( $tag, $attr ) = @_;
if ( $tag =~ /^a$/ and defined $attr->{href} ) {
return
if ( $attr->{href} =~ m!^http://! and $opts{r} )
; # exclude absolute url when -r
return
if ( $attr->{href} !~ m!http://! and $opts{a} )
; # exclude relative url when -a
push @links, $attr->{href};
}
}
$parser->parse($html);
$parser->eof;
foreach $link (@links) {
if ( $link =~ /delete.php/ ) {
$mech->get( “http://m.facebook.com” . $link );
$html_p = HTML::TagParser->new( $mech->content() );
@elem = $html_p->getElementsByTagName(“form”);
$action = $elem[0]->getAttribute(“action”);
@elem = $html_p->getElementsByAttribute( “name”, “fb_dtsg” );
$fb_dtsg = $elem[0]->getAttribute(“value”);
@elem = $html_p->getElementsByAttribute( “name”, “ministory_key” );
$ministory_key = $elem[0]->getAttribute(“value”);
@elem = $html_p->getElementsByAttribute( “name”, “story_type” );
$story_type = $elem[0]->getAttribute(“value”);
@elem = $html_p->getElementsByAttribute( “name”, “profile_id” );
$profile_id = $elem[0]->getAttribute(“value”);
@elem = $html_p->getElementsByAttribute( “name”, “confirm” );
$confirm_id = $elem[0]->getAttribute(“value”);
print “Deleting mini story key: $ministory_key..n”;
$mech->post(
“http://m.facebook.com” . $action,
{
fb_dtsg => $username,
ministory_key => $ministory_key,
story_type => $story_type,
profile_id => $profile_id,
confirm_id => $confirm_id
}
);
sleep(5);
}
}

from the "Lonnie Knows Everything" blog

 

The Greasemonkey solution -and admittedly the easiest for most people- :

Install the Greasemonkey extention

Install the Greasemonkey extention

Restart Firefox and go to http://userscripts.org/scripts/show/92664 and install the "Facebook: Clear ALL Activity" script

Install the Greasemonkey script

install the Greasemonkey script OK

Restart Firefox and visit your profile page. A new button appears above the activity stream, "Remove ALL Activity". Press it and a black hole will vanish your posts!

Remove ALL Activity button

If you want to delete more at once, click "Load More" at the bottom of your activity stream.

Have a nice day! Your Facebook wall is painted to pure white again :)

Notice: You have to use Facebook in English.

Info
References