Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Get data
let newToDelete = [];
for (const element of document.querySelectorAll(".mn-connection-card")) {
newToDelete.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(newToDelete));
/*
* 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
// https://gist.github.com/iddan/89108d40efe2d1b0caa915a0d11313b6
// eventFire(document.getElementById('mytest1'), 'click');
function sleep(i) { return new Promise(resolve => setTimeout(resolve, i)) }
function eventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
let skipped = []
for ([link] of toDelete) {
console.log("link", link)
let l = document.querySelector(`a[href="${link.slice("https://www.linkedin.com".length)}"`);
if (!l)
continue
let card = l.parentElement;
let ellipsisButton = card.querySelector(".mn-connection-card__dropdown button")
eventFire(ellipsisButton, 'click')
await sleep(300);
let buttons = ellipsisButton.parentElement.querySelectorAll("button")
if (buttons.length <= 1) {
console.log("failed at removeConnectionAction.", link)
continue
}
let removeConnectionButton = buttons[buttons.length - 1]
eventFire(removeConnectionButton, 'click')
await sleep(300);
let modal = document.getElementById("artdeco-modal-outlet")
let finalButtons = $(modal).find('button')
if (finalButtons.length <= 1) {
console.log("failed at modal.", link)
continue
}
let finalRemoveButton = finalButtons[finalButtons.length - 1]
eventFire(finalRemoveButton, 'click')
await sleep(300);
}
let nodes = document.querySelectorAll(".artdeco-dropdown__content-inner")
for (node of nodes) {
let removeConnectionButton = node.parentElement.querySelector("button")
console.log("removeConnectionButton", removeConnectionButton)
eventFire(removeConnectionButton, 'click')
await sleep(100);
let modal = document.getElementById("artdeco-modal-outlet")
console.log("modal", modal)
let finalRemoveButton = $(modal).find('button')[2]
console.log("finalRemoveButton", finalRemoveButton)
eventFire(finalRemoveButton, 'click')
await sleep(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment