Skip to content

Instantly share code, notes, and snippets.

@luisvonmuller
Last active April 22, 2021 03:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luisvonmuller/16c60c4bd00f646f4d5a4910b5ca72f1 to your computer and use it in GitHub Desktop.
Save luisvonmuller/16c60c4bd00f646f4d5a4910b5ca72f1 to your computer and use it in GitHub Desktop.
Simple auto invite code for LinkedIn.
var linkedinhoAutoInviter = class {
constructor(maxInvites, actionDelay, pageDelay, ScrollDelay) {
this.pageButtons = [];
this.alreadyInvited = 0;
this.maxInvites = maxInvites;
this.actionDelay = actionDelay;
this.pageDelay = pageDelay;
this.ScrollDelay = ScrollDelay;
}
async invite(invite_button) {
console.log(`[STATUS] - Already invited ${this.alreadyInvited} of total: ${this.maxInvites}`);
if (this.alreadyInvited <= this.maxInvites) {
this.alreadyInvited++;
console.log(`[STATUS] - Inviting another mate... (invite number: ${this.alreadyInvited})`);
invite_button.click();
await new Promise(r => setTimeout(r, this.actionDelay))
let send_button = document.getElementsByClassName("ml1 artdeco-button artdeco-button--3 artdeco-button--primary ember-view");
send_button[0].click();
await new Promise(r => setTimeout(r, this.actionDelay));
} else {
console.info(`[CODE HAS REACHED DESIRED INVATATION AMOUNT]`);
}
}
async getPageButtons() {
/* Search for common stuff */
let butoes = document.getElementsByClassName("artdeco-button artdeco-button--2 artdeco-button--secondary ember-view");
/* Loops over */
for (var counter = 0; counter < butoes.length; counter++) {
if (butoes[counter].lastChild.innerHTML.includes("Connect") || butoes[counter].lastChild.innerHTML.includes("Conectar") ) {
await this.invite(butoes[counter]);
}
}
this.pageButtons = [];
}
async navigate() {
console.log(`[INFO] - Behaving on this new page`);
/* Behave slowly */
await new Promise(r => setTimeout(r, this.ScrollDelay))
window.scrollTo(0, document.body.scrollHeight);
await new Promise(r => setTimeout(r, this.ScrollDelay))
await this.getPageButtons();
/* Getsa the nex button and clicks it */
document.getElementsByClassName("artdeco-pagination__button artdeco-pagination__button--next artdeco-button artdeco-button--muted artdeco-button--icon-right artdeco-button--1 artdeco-button--tertiary ember-view")[0].click();
await new Promise(r => setTimeout(r, this.pageDelay))
if (this.alreadyInvited <= this.maxInvites) {
console.log(`[INFO] - Gonna into next page`);
await this.navigate();
} else {
console.info("We're done!");
}
}
}
var executor = new linkedinhoAutoInviter(10, 500, 3000, 1000);
executor.navigate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment