Using Javascript for mass invitation for a Facebook page


Recently, For a friend’s Facebook page, We need to send invitations to all of his friends. So instead of clicking Invite button for every single person, I preferred to write a small javascript for this.


var a ="_5tef"))[0];if(a);setTimeout(function(){"ul._5kwh li")).forEach(function(c){var d = $(c); var e = d.getElementsByTagName("button")[0]; if(e);})}, 1000);


How to use it

Open Facebook page for which you need to send invites, Make sure there is a peoples section on that page though which invites can be sent.

open console. via right click –> Inspect element –> Console. and pasting above script followed by enter.

How it works

It works as a daemon which will first click on show more friends button and then click invite against all friends listed in that list, one by one.

Key elements to write such scripts or modify this script

You need to know specific components of this script and their usage to modify it

1. document.getElementsByClassName – To select all elements with given class name, which in this case is 5tef (Use inspect element to get this).

2. document.querySelectorAll – To select all friends with specified selector, child <li> with parent class as _5kwh in our case.

3. getElementsByTagName – To get all child buttons which we target to click on.