Skip to content

Instantly share code, notes, and snippets.

@yomeshgupta
Last active February 23, 2021 07:05
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save yomeshgupta/da7b3aebc05997a1cf5058ebb4014530 to your computer and use it in GitHub Desktop.
Save yomeshgupta/da7b3aebc05997a1cf5058ebb4014530 to your computer and use it in GitHub Desktop.
Accept or Reject all connection requests on LinkedIn
// Go to https://www.linkedin.com/mynetwork/invitation-manager/ and run the following code
// For more amazing content, visit -- https://bit.ly/devtools-yt
var ACCEPT_BTN_SELECTOR = ".invitation-card__action-btn:nth-of-type(2)";
var REJECT_BTN_SELECTOR = ".invitation-card__action-btn:nth-of-type(1)";
var DELAY = 2000; // in miliseconds | 2 seconds delay between each request accept
var ACCEPT = true; // set to false if you want to reject all connections
function sleep() {
return new Promise((resolve) => setTimeout(resolve, DELAY));
}
function sleepAndPerformAction(element) {
return sleep().then(() => element.click());
}
async function findRequestsAndPerformAction() {
var requestBtns = document.querySelectorAll(ACCEPT ? ACCEPT_BTN_SELECTOR : REJECT_BTN_SELECTOR);
if (!requestBtns.length) return Promise.reject({ message: "No connection requests found" });
for (let i = 0; i < requestBtns.length; i++) {
await sleepAndPerformAction(requestBtns[i]);
}
}
findRequestsAndPerformAction()
.then(() => console.log("Done"))
.catch(({ message }) => console.log(message));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment