Last active
February 25, 2017 09:41
-
-
Save sdwvit/9ae1ce2cd463dc175e4fcdef05c28d84 to your computer and use it in GitHub Desktop.
Linkedin: delete connections one by one with confirmation
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
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