Last active
April 13, 2022 06:58
-
-
Save zohar-p/6b141f400d1b65737a3da094278f01b7 to your computer and use it in GitHub Desktop.
Dead simple Linkedin automatic connection request sender
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
/** | |
* Go to https://www.linkedin.com/mynetwork/ | |
* Click the `see all` button next to "<OCCUPATION_NAME> you may know" | |
* Paste the code snippet below in the console | |
* Change the `requestsLimit` and `occupationKeywords` according to your needs | |
* Run the code | |
*/ | |
(() => { | |
// Change to the desired number (Linkedin limits you to 80 a day) | |
const requestsLimit = 80 | |
// Change to the desired keywords | |
const occupationKeywords = [ | |
'developer', | |
'development', | |
'programmer', | |
'backend', | |
'back end', | |
'frontend', | |
'front end', | |
'fullstack', | |
'full stack', | |
'r&d', | |
'software', | |
'recruitment', | |
'recruiter', | |
'talent acquisition', | |
'sw engineer', | |
'tech lead' | |
] | |
const getCards = () => document.querySelectorAll('section.discover-entity-type-card') | |
const checkOccupationRelevance = (card) => { | |
const occupationNode = card.querySelector('span.discover-person-card__occupation') | |
// TODO BEFORE PR: Check why sometimes null | |
if (!occupationNode) return false; | |
const occupation = occupationNode.innerText | |
const isRelevantOccupation = occupationKeywords.some((keyword) => occupation.match(new RegExp(keyword, "gi"))) | |
return isRelevantOccupation | |
} | |
const getConnectButton = (card) => { | |
return card.querySelector('footer').querySelector('button') | |
} | |
const checkIfAlreadySent = (connectButton) => { | |
return connectButton.innerText.toLowerCase() === 'pending' | |
} | |
const getName = (card) => card.querySelector('span.discover-person-card__name').innerText | |
const createResultReport = (invitees) => ( | |
`Invited ${invitees.length} people: | |
${invitees.join('\n')} | |
`) | |
const invitees = [] | |
const cards = getCards() | |
for (const card of cards) { | |
if (invitees.length === requestsLimit) return invitees; | |
const isRelevantOccupation = checkOccupationRelevance(card) | |
if (!isRelevantOccupation) continue; | |
const connectButton = getConnectButton(card) | |
const isAlreadySent = checkIfAlreadySent(connectButton) | |
if (isAlreadySent) continue; | |
connectButton.click() | |
const name = getName(card) | |
invitees.push(name) | |
} | |
return createResultReport(invitees) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment