Skip to content

Instantly share code, notes, and snippets.

@lpredova
Forked from zoka123/invite.js
Last active April 9, 2017 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpredova/102a5971a99e5c806b829dc84555e6f5 to your computer and use it in GitHub Desktop.
Save lpredova/102a5971a99e5c806b829dc84555e6f5 to your computer and use it in GitHub Desktop.
Invite
// invite users on post details page
var matches = document.querySelectorAll("a[role=button]");
for(var i = 0; i < matches.length; i++){
var item = matches[i];
if(item.innerHTML == "Invite"){
item.click();
}
}
var matches = document.querySelectorAll("a.uiButton");
for(var i = 0; i < matches.length; i++){
var item = matches[i];
if(item.innerText == "Invite"){
item.click();
}
}
// Method for loading new batch of users and inviting them, just call method and wait for new batch to load, no clicking
function like(){
var numberOfPreviousElements = 0,loading = true, previousStartIndex = 0;
while(loading){
var loadMore = document.querySelectorAll("a.pam.uiBoxLightblue.uiMorePagerPrimary");
if(loadMore.length > 0 && numberOfPreviousElements != loadMore.length){
for(var i = 0; i < loadMore.length; i++){
var item = loadMore[i];
if(item.innerText == "See more"){
item.click();
var matches = document.querySelectorAll('[role="button"]');
for(var i = 0; i < matches.length; i++){
var item = matches[i];
if(item.innerText && item.innerText == "Invite"){
item.click();
console.log("INVITED");
}
}
}
numberOfPreviousElements = loadMore.length;
}
} else {
// No more loading elements
loading = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment