Skip to content

Instantly share code, notes, and snippets.

@laughingclouds
Last active September 25, 2021 07:25
Show Gist options
  • Save laughingclouds/7a1ef263c1e3a9dc655eaff79e8a0758 to your computer and use it in GitHub Desktop.
Save laughingclouds/7a1ef263c1e3a9dc655eaff79e8a0758 to your computer and use it in GitHub Desktop.
The code in this gist allows you to get the list of linkedin connections and followers you have.
/*This checks the names in the connections list against the names in the followers list.
And returns the list of names of people that are not in the followers list*/
function checkConnectionsAgainstFollowers(followers, connections) {
let connectedButNotFollowing = [];
for (let connection of connections) {
if (!followers.includes(connection)) {
connectedButNotFollowing.push(connection);
}
}
return connectedButNotFollowing;
}
// run this on node using ``node functionToCompare.js`` or just run in the console.
# python 3.9.5
def checkConnectionsAgainstFollowers(followers: list[str], connections: list[str]) -> list[str]:
"""This checks the names in the connections list against the names in the followers list.
And returns the list of names of people that are not in the followers list"""
connectedButNotFollowing: list[str] = []
for connection in connections:
if connection not in followers:
connectedButNotFollowing.append(connection)
return connectedButNotFollowing
/*
Connections
navigate to:
https://www.linkedin.com/mynetwork/invite-connect/connections/
*/
Object.values(document.getElementsByClassName("mn-connection-card__name")).map(item => item.innerText);
/*
Followers
navigate to:
https://www.linkedin.com/feed/followers/
*/
Object.values(document.getElementsByClassName('follows-recommendation-card__name')).map(item => item.innerText);
/*
Following
navigate to:
https://www.linkedin.com/feed/following/
*/
Object.values(document.getElementsByClassName("follows-recommendation-card__name")).map(item => item.innerText)
/**
After scrolling to the bottom (lazy loading is enabled and I don't know how to enable eager loading or if it's even possible)
enter these lines in the console. An array with the names should return.
**/

We're making use of the DOM here.

One might be curious as to where these class names come from. These are the classes of the elements that have your follower/connection name as their innerText.

A simple DOM and style inspecting can help you in finding them.

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