Last active
February 23, 2021 07:05
-
-
Save yomeshgupta/da7b3aebc05997a1cf5058ebb4014530 to your computer and use it in GitHub Desktop.
Accept or Reject all connection requests on LinkedIn
This file contains hidden or 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
// 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