Skip to content

Instantly share code, notes, and snippets.

@ferbass
Last active December 29, 2022 03:22
Show Gist options
  • Save ferbass/165143e70a94925d2cd9e56ae6874031 to your computer and use it in GitHub Desktop.
Save ferbass/165143e70a94925d2cd9e56ae6874031 to your computer and use it in GitHub Desktop.
Linkedin unfollow all
function isHidden(el) {
if(el) return (el.offsetParent === null);
else return false;
}
TotalUnfollowed = 0;
var LoadingAnimation = document.getElementsByClassName("initial-load-animation")[0];
var CatchLoadingAnimation = setInterval(function(){
if(isHidden(LoadingAnimation) == true) {
clearInterval(CatchLoadingAnimation);
/* START: RUN AFTER PAGE LOAD COMPLETE */
/* SHOW STATUS AND CONFIRMATION ELEMENT */
var LiUnfollow = document.createElement("div");
LiUnfollow.id = "LiUnfollow";
LiUnfollow.innerHTML = "<div style=\"color: aliceblue; background-color: #005E93; border-bottom: 1px solid #ced0d4; padding: 7.5px; text-align: center;\">LinkedIn Unfollower</div><div name=\"Confirmation\"><div style=\"font-size: 14px; color: #4b4f56; text-align: center; margin: 7.5px; display: block; cursor: default;\">Ready To Unfollow Everyone?</div><div style=\"background-color: #005E93; border-top: 1px solid #ced0d4; padding: 7.5px;\"><button type=\"button\" name=\"Continue\" style=\"background-color: #f6f7f9; color: #4b4f56; border: 1px solid #ced0d4; padding: 0 8px; line-height: 27.5px; font-weight: normal; font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; \">Yes</button><button type=\"button\" name=\"Close\" style=\"background-color: #f6f7f9; color: #4b4f56; border: 1px solid #ced0d4; padding: 0 8px; line-height: 27.5px; font-weight: normal; font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px; margin-left: 7.5px;\">No</button></div></div><div name=\"Status\" style=\"display: none;\"><div style=\"font-size: 14px; color: #4b4f56; margin: 7.5px; display: block; cursor: default;\"><div name=\"Message\" style=\"display: none;\">Unfollowed Successfully!</div>Total Unfollowed: <span name=\"TotalUnfollowed\">0</span></div><div style=\"background-color: #005E93; border-top: 1px solid #ced0d4; padding: 7.5px;\"><button type=\"button\" name=\"Stop\" style=\"background-color: #f6f7f9; color: #4b4f56; border: 1px solid #ced0d4; padding: 0 8px; line-height: 27.5px; font-weight: normal; font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 14px;\">Stop</button></div></div>";
LiUnfollow.style = "width: 300px; height: auto; background: #f6f7f9; z-index: 9999999999; position: fixed; top: calc(50% - 100px); right: calc(50% - 150px); border: 1px solid #ced0d4; border-radius: 2px; font-family: -apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: medium; font-weight: normal;";
document.body.appendChild(LiUnfollow);
/* ONCLICK EVENTS */
/* NO BUTTON */
if(document.querySelectorAll("#LiUnfollow [name=Close]")[0]) document.querySelectorAll("#LiUnfollow [name=Close]")[0].onclick = function() {
document.querySelectorAll("#LiUnfollow")[0].outerHTML = "";
};
/* YES BUTTON */
if(document.querySelectorAll("#LiUnfollow [name=Continue]")[0]) document.querySelectorAll("#LiUnfollow [name=Continue]")[0].onclick = function() {
document.querySelectorAll("#LiUnfollow [name=Confirmation]")[0].style.display = "none";
document.querySelectorAll("#LiUnfollow [name=Status]")[0].style.display = "block";
UnfollowFunction = setInterval(function() {
var UnfollowButton = document.querySelectorAll("ul > li [data-control-name=\"actor_follow_toggle\"].is-following");
for(var i = UnfollowButton.length - 1; i>=0; i--) {
TotalUnfollowed++;
UnfollowButton[i].click();
document.querySelectorAll("#LiUnfollow [name=TotalUnfollowed]")[0].innerHTML = Number(document.querySelectorAll("#LiUnfollow [name=TotalUnfollowed]")[0].innerHTML) + 1;
}
}, 1000);
ScrollToBottom = setInterval(function() {
window.scrollBy(0, 12.5);
}, 15);
function CheckPageEnd(LastHeight) {
var CurrentHeight = document.body.scrollHeight;
if(!(CurrentHeight > LastHeight)) {
clearInterval(ScrollToBottom);
clearInterval(UnfollowFunction);
document.querySelectorAll("#LiUnfollow [name=Message]")[0].style.display = "block";
document.querySelectorAll("#LiUnfollow [name=Stop]")[0].innerHTML = "Close";
} else setTimeout(function() {
CheckPageEnd(CurrentHeight);
}, 7.5*1000);
}
CheckPageEnd(0);
}
/* STOP BUTTON */
if(document.querySelectorAll("#LiUnfollow [name=Stop]")[0]) document.querySelectorAll("#LiUnfollow [name=Stop]")[0].onclick = function() {
clearInterval(ScrollToBottom);
clearInterval(UnfollowFunction);
document.querySelectorAll("#LiUnfollow")[0].outerHTML = "";
};
/* END: RUN AFTER PAGE LOAD COMPLETE */
}
}, 1000);
@Prodave81
Copy link

Hello @ferbass, many thanks for this hack! How are make "follow all" again??? you know? Many Thanks!

@ferbass
Copy link
Author

ferbass commented Dec 28, 2022

Hey @Prodave81, this script is outdated,Linkedin already changed the layout tags.
I just found that link for a mass follows https://victormochere.com/how-to-mass-follow-people-on-linkedin, that might help you with your issue.

Good lucky :)

@Prodave81
Copy link

Hey @Prodave81, this script is outdated,Linkedin already changed the layout tags. I just found that link for a mass follows https://victormochere.com/how-to-mass-follow-people-on-linkedin, that might help you with your issue.

Good lucky :)

Thankss @ferbass! Very interesting. I saw the post, but y can`t see the code for mass follow in the post, dou you know how is the code for follw?
Thanksss

@ferbass
Copy link
Author

ferbass commented Dec 29, 2022

@Prodave81 sorry about that, in that case is better to message the post author and ask for the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment