Created
January 5, 2025 08:38
-
-
Save meta-ks/b4e2792074785e3f1f18f187f04e036f to your computer and use it in GitHub Desktop.
This script automates withdrawing all pending LinkedIn invitations. Run it in your browser console on the "Manage Invitations" page. Change the timeout if required. Works as on Jan 5, 2025
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
(async () => { | |
const liElements = document.querySelectorAll('.artdeco-list.mn-invitation-list li'); | |
const total = liElements.length; | |
for (let idx = 0; idx < total; idx++) { | |
console.log(`Withdrawing ${idx + 1}/${total}...`); | |
const li = liElements[idx]; | |
const withdrawButton = li.querySelector('button'); // Initial "Withdraw" button | |
if (withdrawButton && withdrawButton.textContent.trim() === 'Withdraw') { | |
withdrawButton.click(); // Click the "Withdraw" button | |
await new Promise(resolve => setTimeout(resolve, 2000)); // Wait 4 seconds for confirmation modal | |
// Find and click the confirmation "Withdraw" button | |
const overlayWithdrawButton = document.querySelector( | |
'.artdeco-button.artdeco-button--2.artdeco-button--primary.ember-view.artdeco-modal__confirm-dialog-btn' | |
); | |
if (overlayWithdrawButton) { | |
overlayWithdrawButton.click(); // Click confirmation button | |
await new Promise(resolve => setTimeout(resolve, 3000)); // Wait 2 seconds before next item | |
console.log(`Withdrawn ${idx + 1}/${total}.`); | |
} else { | |
console.log(`Confirmation "Withdraw" button not found for item ${idx + 1}.`); | |
break; // Exit if modal interaction fails to prevent unintended behavior | |
} | |
} else { | |
console.log(`"Withdraw" button not found for item ${idx + 1}. Skipping.`); | |
} | |
} | |
console.log('All withdrawn'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment