views:

493

answers:

2

Moaning about the lack of a dislike button is all the rage on Facebook at the moment and various groups have sprung up offering a dislike button, but only after you've invited x amount of your friends.

One of the more (possibly devious?) groups requires you to run Javascript as part of the joining process. I haven't ever done web coding so I'm wondering if someone can tell me what the following code does?

javascript:elms=document.getElementById('friends').getElementsByTagName('li');
for(var fid in elms){
     if(typeof elms[fid] === 'object'){
          fs.click(elms[fid]);
     }
}

The link to the group is here: |►OFFICIAL Dislike Button™ is Finally Here◄| Add it Now, it ACTUALLY WORKS!. The code is listed under the 3 steps in the recent news section.

A: 

This will fetch all the li elements in the element with the id 'friends' and then loop through them and if it's an 'object' perform fs.click(elms[fid])

AntonioCS
Translation: invites all your friends to the group.
Matchu
-1 This doesn't really say what the code does, anyone with enough experience in programming could have gleamed this from the code.
JPvdMerwe
So I do say what the code does, but not what you really wanted.. great.. next time I will try to read your mind before answering
AntonioCS
+7  A: 
// Find the Element in the webpage that has the ID "friends", which is the list of your friends ;-)
javascript:elms=document.getElementById('friends').getElementsByTagName('li'); 
// Iterate over every friend in the list
for(var fid in elms){ 
     // just a validation
     if(typeof elms[fid] === 'object'){ 
          // Click on the invite to Group button
          fs.click(elms[fid]); 
     } 
} 

Basically, this code causes a group invitation for all of your friends ;-)

Mef