-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwithdraw_connections.js
26 lines (20 loc) · 1.01 KB
/
withdraw_connections.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
async function withdrawAllInvitations(maxWithdrawals = Infinity) {
const withdrawButtons = document.querySelectorAll('button[aria-label^="Withdraw invitation sent to"]');
let withdrawalsCount = 0;
for (const button of withdrawButtons) {
if (withdrawalsCount >= maxWithdrawals) break;
button.click();
// Wait for the dialog to appear, with some variability
await new Promise(resolve => setTimeout(resolve, 500 + Math.random() * 1000));
const confirmButton = [...document.querySelectorAll('.artdeco-modal__confirm-dialog-btn')].find(btn =>
btn.querySelector('span')?.innerText.includes('Withdraw')
);
if (confirmButton) {
confirmButton.click();
withdrawalsCount++;
// Wait for the dialog to be processed, with some variability
await new Promise(resolve => setTimeout(resolve, 500 + Math.random() * 1000));
}
}
console.log(`Withdrawn ${withdrawalsCount} invitations`);
}