Stop Facebook Spam Javascript To Remove All Facebook Apps From Your Account



This is a guest post by Gaganpreet Arora AKA bitgeek.

My Facebook app list was cluttered with useless apps accumulated over the time I had joined Facebook. The worst thing is that Facebook does not allow you to remove multiple apps in one go. You have to select one, confirm on “Are you sure?” first and then click on “Okay” when it is deleted. Very cumbersome. So I wrote a Javascript hack to remove all of the apps in one go.

Warning: This will actually delete all the apps

Step 1

Go to: http://www.facebook.com/editapps.php?v=allowed.

Step 2

Select and copy the complete code below and paste it into the address bar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
javascript:
function postwith (to,p) 
{
  var myForm = document.createElement("form"); 
  myForm.method="post" ; myForm.action = to ; 
  for (var k in p) 
  {
    var myInput = document.createElement("input") ; 
    myInput.setAttribute("name", k) ; 
    myInput.setAttribute("value", p[k]);  
    myForm.appendChild(myInput) ; 
  } 
  document.body.appendChild(myForm) ; 
  myForm.submit() ; 
  document.body.removeChild(myForm) ;
}
 
function getElementsByClassName(classname, node) 
{ 
  if (!node) 
  { 
    node = document.getElementsByTagName('body')[0]; 
  } 
  var a = [], re = new RegExp('\\b' + classname + '\\b'); 
  els = node.getElementsByTagName('*'); 
  for (var i = 0, j = els.length; i < j; i++) 
  { 
    if ( re.test(els[i].className) ) 
    { a.push(els[i]); } 
  } 
  return a; 
}
 
var arr = []; 
els=document.getElementsByClassName('app_row'); 
arr['fb_dtsg']=document.getElementsByName('fb_dtsg')[0].value; 
arr['remove'] = 1;  
arr['post_form_id_source']='AsyncRequest'; 
arr['post_form_id'] = document.getElementById('post_form_id').value; 
arr['app_id']=els[0].id.replace("editapps_allowed_","");   
arr['__a'] = 1; 
for (i=0; i<els.length; ++i) 
{postwith("http://facebook.com/ajax/edit_app_settings.php", arr); arr['app_id'] = els[i+1].id.replace("editapps_allowed_","");}

Step 3

Press Enter.

The browser may get stuck for a few moments if the list is large, so if it does, just wait a bit and it will respond back.

References

Function postwith was taken from here, and getElementsByClassName was taken from here.


Share

  • del.icio.us
  • Digg
  • Twitter
  • StumbleUpon
  • Reddit

Related Posts

Javascript To Remove All Facebook Apps From Your Account

{ 1 trackback }

כיצד להסיר את כל האפליקציות בחשבון הפייסבוק | The IceMan
March 24, 2010 at 4:38 PM

{ 3 comments… read them below or add one }

1 Sanrag February 12, 2010 at 7:42 AM

Suggestion: You can turn this into a greasemonkey script which removes the confirmation dialog… so you just click on the (x) button and the application is removed… Handy and convenient…

P.S. Didn’t work in Chrome..

Reply

2 TIM March 24, 2010 at 4:51 PM

The code isn’t working for me for some reason. tested on FF and Opera

Reply

3 Ben Carroll May 3, 2010 at 7:08 PM

Doesn’t work for me either.. Tested in FF and Chrome

Reply

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post: News : ATI Catalyst Drivers 10.1 Released. Test them now!

Next post: News: ATI Catalyst Drivers 10.2 Released. No Fedora 12 Support.