DEV Community

loading...
Cover image for Increase LinkedIn Connections with this automation script 🎨

Increase LinkedIn Connections with this automation script 🎨

manitej profile image Manitej ⚡ ・2 min read

Growing your network on LinkedIn is time taking. So I tried to automate the process of connecting to my suggested network to increase my network

Usage

  1. Go to this link

Alt Text

  1. Click on see all button

Alt Text

  1. Right-click and go to the console tab. Now copy the below script and paste it to the console and hit enter. Wait for some time to see the magic ✨
async function moreConnectionsPlease() {
  // maximum limit of Connect buttons clicked
  const LIMIT = 500;
  // wait in ms before each scroll
  const SCROLL_TIMEOUT = 600;
  // bulk scroll will scroll this amount of times
  const BULK_SCROLL_COUNT = 15;
  // wait in ms before each click
  const CLICK_DELAY = 300;
  // if this amount of connections in the page, time to click
  const MINIMUM_CONNECTS_TO_CLICK = 60;
  // if this amount of connections in the page, time to scroll
  const MINIMUM_CONNECTS_TO_SCROLL = 10;

  var connects = 0;
  var fails = 0;

  // retrieves array "Connect" buttons
  function selectButtonElements() {
    return [...document.querySelectorAll("button span")].filter(a =>
      a.textContent.includes("Connect")
    );
  }

  // scrolls to the bottom of the page
  async function singleScroll() {
    return new Promise(resolve => {
      setTimeout(() => {
        window.scrollTo(0, document.body.scrollHeight);
        console.log("scroll!");
        resolve();
      }, SCROLL_TIMEOUT);
    });
  }

  // delays an html element click
  async function singleClick(elem) {
    return new Promise(resolve => {
      setTimeout(() => {
        elem.click();
        resolve();
      }, CLICK_DELAY);
    });
  }

  // scroll to the bottom of the page several times
  async function bulkScroll() {
    for (let i = 0; i < BULK_SCROLL_COUNT; i++) {
      await singleScroll();
    }
  }

  // click on all but a few Connect buttons
  async function bulkClick() {
    let elements = selectButtonElements();
    console.log("elements length:", elements.length);
    for (let i = 0; i < elements.length - MINIMUM_CONNECTS_TO_SCROLL; i++) {
      try {
        await singleClick(elements[i]);
        console.log("click!");
        connects++;
      } catch (err) {
        fails++;
      }
    }
  }

  // the list of people to connect to must keep a minimum amount of people
  function isManyConnects(amount) {
    return selectButtonElements().length >= amount;
  }

  do {
    if (isManyConnects(MINIMUM_CONNECTS_TO_CLICK)) {
      console.log("There are plenty of connections, time to click...");
      await bulkClick();
    } else {
      console.log("Out of connections, need to scroll...");
      await bulkScroll();
    }
    console.log(`New Connections:${connects} Failed clicks:${fails}`);
  } while (connects < LIMIT);
}

moreConnectionsPlease();
Enter fullscreen mode Exit fullscreen mode

Alt Text

The script will send connection requests to all suggestions. Wait for some time to get accepted

Repo

Give it a ⭐ if you found this useful

Script reference

https://gist.github.com/bertolo1988/9d285c4ac2b2c10c6026d74a671da9f9

Note: This post is just to show you the power of javascript, do it at your own risk

Discussion (3)

pic
Editor guide
Collapse
shriji profile image
Shriji

This could result you in a ban!

Collapse
zed profile image
zed

This misses the point of having LinkedIn connections. The overall goal is not to have more connections, but more quality connections.

A quality connection starts with a personalised note with every connection request. A "thanks for connecting" DM after accepting anyone else's request. And continues with increased interactions on the platform.

Collapse
sanatjha profile image