Skip to content

Instantly share code, notes, and snippets.

@iddan
Last active December 6, 2021 11:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iddan/89108d40efe2d1b0caa915a0d11313b6 to your computer and use it in GitHub Desktop.
Save iddan/89108d40efe2d1b0caa915a0d11313b6 to your computer and use it in GitHub Desktop.
Batch delete connections on LinkedIn
// 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