Created
June 1, 2017 12:55
-
-
Save max-frai/57618dcbd60b4521ce84d671baf8fdce to your computer and use it in GitHub Desktop.
Invite people to facebook 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 INVITE_PEOPLE_COUNT = 100; | |
var scroll = document.querySelector('form[action*="invite"] .fbProfileBrowserResult'); | |
var lastScroll = -1; | |
var it = 0; | |
var inviteIt = 0; | |
var allInvites = []; | |
var invitePause = 1000; // ms | |
function doInvite() | |
{ | |
console.log('Start inviting'); | |
var S = window.localStorage; | |
var userInvited = 0; | |
var pageId = document.querySelector('form[action*="invite"] div[data-batch*="page_id"]') | |
.getAttribute('data-batch').match(/\d+/)[0]; | |
console.log('page id: ' + pageId); | |
var alreadyInvitedList = []; | |
var storage = S.getItem(pageId); | |
if (storage != undefined) | |
alreadyInvitedList = JSON.parse(storage); | |
var accounts = document.querySelectorAll('form[action*="invite"] .fbProfileBrowserResult li'); | |
console.log('Found invite buttons: ' + accounts.length); | |
var INTERVAL2 = window.setInterval(function() { | |
if (inviteIt >= accounts.length || userInvited == INVITE_PEOPLE_COUNT) | |
{ | |
window.clearInterval(INTERVAL2); | |
S.setItem(pageId, JSON.stringify(alreadyInvitedList)); | |
console.log('FINISH'); | |
} | |
else | |
{ | |
inviteIt += 1; | |
var account = accounts[inviteIt]; | |
var aid = account.getAttribute('data-uid'); | |
if (alreadyInvitedList.indexOf(aid) == -1) | |
{ | |
console.log('Invite user: ' + aid); | |
alreadyInvitedList.push(aid); | |
account.querySelector('a.uiButton').click(); | |
userInvited += 1; | |
} | |
else | |
{ | |
console.log('Already invited: ' + aid); | |
} | |
} | |
}, invitePause); | |
} | |
var INTERVAL = window.setInterval(function() { | |
console.log('Wait...'); | |
if (it >= 7) | |
{ | |
doInvite(); | |
window.clearInterval(INTERVAL); | |
} | |
it = (scroll.scrollTop == lastScroll) ? (it+1) : 0; | |
lastScroll = scroll.scrollTop; | |
var seeMore = document.querySelector('#reaction_profile_pager .uiMorePagerPrimary'); | |
if (seeMore) | |
seeMore.click(); | |
scroll.scrollTop += 1000; | |
}, 400); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hello where can i get a script to add my facebook friend to a facebook group.