Automate Invitation Withdrawals LinkedIn Script

Automate Invitation Withdrawals LinkedIn Script

In today's hyper-connected world, keeping your LinkedIn network organized is super important. But let's be honest, who has the time to manually withdraw all those pending connection requests? If you want to clean up your requests, this game-changing script hack is just what you need!

How to use this script

  • Log in to LinkedIn:

    • Open your web browser and log in to your LinkedIn account.
  • Navigate to the Sent Invitations Page:

    • Go to the following URL: LinkedIn Sent Invitations Manager

    • Now you'll need to open the browser's Developer Tools:

    • Right-click anywhere on the page and select "Inspect" or press Ctrl + Shift + I (Windows/Linux) or Cmd + Option + I (Mac).

(async function() {
    const maxLimit = undefined; // Specify max number of invitations to withdraw or define undefined for all
    const invitations = getInvitations();
    for (let invitation of invitations) {
        if (maxLimit !== undefined && invitations.indexOf(invitation) >= maxLimit) return;
        const actionButton = invitation.querySelector('button.invitation-card__action-btn');
        await clickActionButton(actionButton);
        console.log(`-----------------------Withdraw invitation script completed-----------------------`);
        console.log(`-----------------------${invitations.length} pending invitation withdrawn-------------------------------`);

function getInvitations() {
    return document.querySelectorAll("div.invitation-card__action-container");

async function clickActionButton(actionButton) {;
    await waitAndClickPrimaryButton();

async function waitAndClickPrimaryButton() {
    return new Promise((resolve) => {
        const intervalId = setInterval(() => {
            if (document.querySelector('[data-test-modal-container] > [data-test-modal] [data-test-dialog-primary-btn]')) {
                document.querySelector('[data-test-modal-container] > [data-test-modal] [data-test-dialog-primary-btn]').click();
                setTimeout(resolve, 1000);

Boom! That's it! Your pending requests will be removed. If you have more than 100 requests, you'll need to refresh the page and paste the script again.

🤝 Let's connect on LinkedIn or Twitter where I share tech insights.

🎥 Follow me on my YouTube channel for videos on Mobile App Development and Back end Development.