Skip to content

Instantly share code, notes, and snippets.

@IgorHalfeld
Created July 28, 2020 00:13
Show Gist options
  • Save IgorHalfeld/ba8f97250d2f5bd09ce18aede0183616 to your computer and use it in GitHub Desktop.
Save IgorHalfeld/ba8f97250d2f5bd09ce18aede0183616 to your computer and use it in GitHub Desktop.
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('.full-width.artdeco-button.artdeco-button--2.artdeco-button--full.artdeco-button--secondary.ember-view') || [];
}
async function connect() {
const buttons = getAllButtons();
for (let button of buttons) {
count = count + 1;
const name = document.querySelector(
'.discover-person-card__name.t-16.t-black.t-bold'
).textContent;
window.scrollTo(0, button.offsetTop - 260);
const label = button.children[0].textContent
if (/connect/i.test(label)) {
console.log(`Connect #${count}:`, name);
button.click();
}
await new Promise((resolve) => setTimeout(resolve, 400));
}
}
async function run() {
await connect();
window.scrollBy(0, document.body.scrollHeight);
await new Promise((resolve) => setTimeout(resolve, 1000));
const buttons = getAllButtons();
if (buttons.length) run();
}
run();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment