-
To unfollow new connections (followers):
- Go to: LinkedIn Followers
- Open Dev Tools > Console (Cmd+Option+J or Ctrl+Shift+J).
- Paste the script below into the console and press enter.
-
To unfollow people you are explicitly following:
- Go to: LinkedIn Following
- Open Dev Tools > Console (Cmd+Option+J or Ctrl+Shift+J).
- Paste the script below into the console and press enter.
(() => {
let count = 0;
// Function to get all buttons matching the aria-label pattern
function getAllButtons() {
return Array.from(
document.querySelectorAll('button[aria-label^="Click to stop following"]')
);
}
// Function to handle the unfollow process
async function unfollowAll() {
const buttons = getAllButtons();
for (let button of buttons) {
count += 1;
// Extract name if available for logging purposes
const name = button.closest('div')?.querySelector(
'.follows-recommendation-card__name'
)?.innerText || 'Unknown';
console.log(`Unfollow #${count}:`, name);
// Scroll to the button and click it
window.scrollTo(0, button.offsetTop - 260);
button.click();
// Wait for the modal to appear
await new Promise((resolve) => setTimeout(resolve, 500));
// Find and click the 'Unfollow' button in the modal
const unfollowButton = Array.from(document.querySelectorAll('button')).find(
(btn) => btn.innerText.trim() === 'Unfollow'
);
if (unfollowButton) {
unfollowButton.click();
} else {
console.warn(`Unfollow button not found for #${count}:`, name);
}
// Delay between actions to avoid overwhelming the website
await new Promise((resolve) => setTimeout(resolve, 1000));
}
}
// Main function to iterate over the buttons until all are processed
async function run() {
await unfollowAll();
window.scrollTo(0, document.body.scrollHeight);
// Wait and recheck for new buttons (if dynamically loaded)
await new Promise((resolve) => setTimeout(resolve, 2000));
const buttons = getAllButtons();
if (buttons.length) {
console.log('More buttons detected, continuing...');
run();
} else {
console.log('No more buttons to process.');
}
}
// Start the script
run();
})();
- This script handles dynamically loaded buttons as well.
- Ensure you have a stable internet connection while running the script.
- Use responsibly.