Linkedin: delete connections one by one with confirmation
const keywords = ['recru', 'apply', 'looking for', 'hr', 'talent']; | |
const names = $('.mn-person-info__name'); | |
const positions = $('.mn-person-info__occupation'); | |
const dropdowns = $('.mn-connections__dropdown-trigger'); | |
const deleteButtonSelector = () => $('.mn-connections__dropdown-option-btn'); | |
const confirmButtonSelector = () => $('.remove-btn'); | |
let connections = {}; | |
for (let i = 0; i < names.length; i++) { | |
connections[names[i].innerText] = { | |
name: names[i].innerText, | |
position: positions[i].innerText, | |
delete: () => { | |
dropdowns[i].click(); | |
deleteButtonSelector()[0].click(); | |
confirmButtonSelector()[0].click(); | |
} | |
} | |
} | |
Object.keys(connections).forEach((el, i) => { | |
keywords.forEach((word) => { | |
if (connections[el].position.toLowerCase().match(word) && confirm(`Delete connection ${connections[el].name}?`)) { | |
try { | |
connections[el].delete(); | |
} catch (e) { | |
console.error('Failed to delete', connections[el]); | |
} | |
} | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment