Last active
December 6, 2021 11:39
-
-
Save iddan/89108d40efe2d1b0caa915a0d11313b6 to your computer and use it in GitHub Desktop.
Batch delete connections on LinkedIn
This file contains 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
// Get data | |
let d = []; | |
for (const element of document.querySelectorAll(".mn-connection-card")) { | |
d.push([element.querySelector("a").href, element.querySelector(".mn-connection-card__name").textContent.trim(), element.querySelector(".mn-connection-card__occupation").textContent.trim()]) | |
} | |
// Copy data to clipboard | |
copy(JSON.stringify(d)); | |
/* | |
* Paste the data and filter out a list of people you want to delete | |
*/ | |
// Replace the array here with the list of people you want to delete | |
var toDelete = [] | |
function sleep(i) { return new Promise(resolve => setTimeout(resolve, i)) } | |
// Delete data | |
for ([link] of toDelete) { | |
let l = document.querySelector(`a[href="${link.slice("https://www.linkedin.com".length)}"`); | |
if (!l) | |
continue | |
let card = l.parentElement; | |
let deleteEl = card.querySelector("artdeco-dropdown-content button") | |
deleteEl.click(); | |
// Wait for modal to open up | |
await sleep(10); | |
let buttons = Array.from(document.getElementById("artdeco-modal-outlet").querySelectorAll("button")) | |
buttons[buttons.length - 1].click() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment