If you have problem with remove multiple LinekedIn connections at once, this code may help you.
In this code there is a filter that checks conection's occupation and based on that it will remove some connections.
Use some keyword to filter your connections and remove some.
In order to use this script open your connections page at linkedin.com quick open, then go to page inspect view and in the console paste the code below press Enter and wait till finishes it's job.
This code is not so fast because it needs some seconds to let the dorpdowns and modals pop up and also the list is calculated in each interval from scratch. sure this script could be far better but I'm not a js developer nor had the time to think about the corners there. so fill free to make it better and send me your optimized version. Thanks in advance.
// Function to remove connection
function removeConnection (connection) {
// Click the button to initiate removal
let button = connection.querySelector('.artdeco-dropdown__trigger');
if (button) {
button.click();
// Wait for dropdown to open and click "Remove connection" button
setTimeout(() => {
let removeButton = connection.querySelector('.mn-connection-card__dropdown-option-text');
if (removeButton) {
removeButton.click();
// Wait for confirmation dialog to open and click "Remove" button
setTimeout(() => {
let confirmButton = document.querySelector(".artdeco-button.artdeco-button--2.artdeco-button--primary.ember-view.artdeco-modal__confirm-dialog-btn");
if (confirmButton) {
confirmButton.click();
} else {
console.log('Remove button not found in confirmation dialog.');
}
}, 300); // Adjust timeout as needed
} else {
console.log('Remove button not found in dropdown.');
}
}, 100); // Adjust timeout as needed
} else {
console.log('Button not found.');
}
}
function collectAndFilterConnections () {
// Find all connections (li tags)
let connections = document.querySelectorAll('li.mn-connection-card');
// Keywords to filter connections
let keywords = ["hr", "human", "human resource", "art", "nail", "student", "c#", ".net", ];
// Iterate over each connection and remove if it mentions any of the keywords
for (let connection of connections) {
let occupationSpan = connection.querySelector('.mn-connection-card__occupation');
if (occupationSpan) {
let occupationText = occupationSpan.textContent.toLowerCase();
// Check if the occupation contains any of the keywords
if (keywords.some(keyword => occupationText.includes(keyword))) {
// Add a short timeout between each removal
removeConnection(connection);
break;
}
}
}
}
setInterval(collectAndFilterConnections, 2000);