-
-
Save lpredova/102a5971a99e5c806b829dc84555e6f5 to your computer and use it in GitHub Desktop.
Invite
This file contains 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
// 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