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
// this function allows us to stop our code for |ms| milliseconds. | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
// I've put our main code into this function. | |
async function addPeople() { | |
ul = $('ul.mn-pymk-list__cards')[0]; | |
firstLi = ul.querySelector('li'); | |
count = 0; // this is the count of how many people you've added | |
while(firstLi && count < 100){ // stop after adding 100 people | |
buttonToClick = firstLi.querySelector("button[data-control-name=invite]"); | |
// make sure that this button contains the text "Connect" | |
if (buttonToClick.innerText.includes("Connect")){ | |
buttonToClick.click(); | |
count += 1; | |
console.log("I have added " + count + " people so far."); | |
} | |
ul.removeChild(firstLi); | |
await sleep(1000); // stop this function for 1 second here. | |
firstLi = ul.querySelector('li'); | |
} | |
} | |
addPeople(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The 8th line in code .... has to be replaced with
ul = $("ul#ember1225")[0];
to work , as UI side changes has been made .