Last active
December 23, 2024 12:51
-
-
Save brunolemos/8e13c5472b0c07d795aa766423569546 to your computer and use it in GitHub Desktop.
Unfollow everyone on Linkedin
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
(() => { | |
let count = 0; | |
function getAllButtons() { | |
return document.querySelectorAll('button.is-following') || []; | |
} | |
async function unfollowAll() { | |
const buttons = getAllButtons(); | |
for (let button of buttons) { | |
count = count + 1; | |
const name = button.parentElement.querySelector( | |
'.follows-recommendation-card__name', | |
).innerText; | |
console.log(`Unfollow #${count}:`, name); | |
window.scrollTo(0, button.offsetTop - 260); | |
button.click(); | |
await new Promise((resolve) => setTimeout(resolve, 100)); | |
} | |
} | |
async function run() { | |
await unfollowAll(); | |
window.scrollTo(0, document.body.scrollHeight); | |
await new Promise((resolve) => setTimeout(resolve, 1000)); | |
const buttons = getAllButtons(); | |
if (buttons.length) run(); | |
} | |
run(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I created a new script inspired by this which works with current LinkedIn web app https://gist.github.com/pankaj28843/df69413be464756c63506bbaed97dde2