Last active
October 19, 2017 00:36
-
-
Save sayhicoelho/84a170485be1a82a488e699f83f00e93 to your computer and use it in GitHub Desktop.
Facebook: Invite your friends to like a Page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var list = document.getElementsByClassName('lists')[0]; | |
var min = 500; // ms | |
var max = 1500; // ms | |
var time = min; | |
var interval; | |
var timeout; | |
var invited = 0; | |
var limit = 999; | |
var stop = false; | |
function getRandomInt(min, max) | |
{ | |
min = Math.ceil(min); | |
max = Math.floor(max); | |
return Math.floor(Math.random() * (max - min)) + min; | |
} | |
function inviteFriend() | |
{ | |
timeout = setTimeout(function () { | |
if (stop == true) { | |
console.log('Stopped!'); | |
return; | |
} | |
var friends = list.querySelectorAll('.fbProfileBrowserListItem:not(._1so) .uiButton'); | |
var total = list.querySelectorAll('.fbProfileBrowserListItem').length; | |
console.clear(); | |
console.log('Friends loaded: ' + total); | |
console.log('Invited: ' + invited); | |
if (friends.length > 0) { | |
time = getRandomInt(min, max); | |
invited++; | |
friends[0].click(); | |
if (invited > limit) | |
{ | |
clearInterval(interval); | |
console.log('You\'ve reached on the limit of ' + limit + ' invites. Please, try again tomorrow to prevent you get blocked by Facebook to invite other friends.'); | |
stop = true; | |
} | |
} | |
inviteFriend(); | |
}, time); | |
} | |
function start() | |
{ | |
inviteFriend(); | |
var container = document.getElementsByClassName('fbProfileBrowserResult')[0]; | |
var last = null; | |
interval = setInterval(function () { | |
if (stop == true) { | |
clearInterval(interval); | |
console.log('Stopped!'); | |
return; | |
} | |
if (last == null || container.scrollTop != last) | |
{ | |
last = container.scrollTop; | |
container.scrollTop += 50; | |
} | |
else | |
{ | |
clearInterval(interval); | |
console.log('The scroll reached the end of the bottom.'); | |
if (list.querySelectorAll('.fbProfileBrowserListItem:not(._1so) .uiButton').length == 0) { | |
stop = true; | |
} | |
} | |
}, 50); | |
} | |
start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment