Skip to content

Instantly share code, notes, and snippets.

@vneri
Last active February 21, 2020 20:44
Show Gist options
  • Save vneri/0331f2f1ad9642bda46fbf3861017e36 to your computer and use it in GitHub Desktop.
Save vneri/0331f2f1ad9642bda46fbf3861017e36 to your computer and use it in GitHub Desktop.
Auto Invite Facebook Post Likers, with load more and safety timer
// copy and paste this into the web console (open with F12)
// setup the text of the invitation and the "load more" button based on your language
// don't set the delay too low or you will be banned
// in test
var invitationButton = 'Einladen';
var loadMoreButton = 'Mehr anzeigen';
function Sleep(milliseconds) {
return new Promise(resolve => setTimeout(resolve, milliseconds));
}
function clickOnInvitationButtons(){
var a = document.querySelectorAll('a[role=button]')[0];
a.style.border = "2px solid red";
console.log('Searching Invitation buttons...');
if (a.innerText == invitationButton){
console.log('Invite '+ a);
a.style.border = "2px solid green";
a.click();
a.parentElement.removeChild(a);
return true;
} else {
return false;
}
}
window.setInterval(function(){
// check if there are more buttons
var buttons = document.querySelectorAll('a[role=button]');
if (buttons == undefined || buttons.length > 0){
var clickResult = false;
while (! clickResult){
// click until one has been found and then go to the waiting loop
clickResult = clickOnInvitationButtons();
}
} else {
clickOnMoreButtons();
}
}, 1000);
// click load more
function clickOnMoreButtons(){
document.querySelectorAll('.uiMorePagerPrimary').forEach(async function(a){
console.log('Load More Button '+ a);
if (a.innerText == loadMoreButton){
await Sleep(5000);
a.click();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment