Last active
May 31, 2023 21:58
-
-
Save prafulfillment/73fd70f399d6cae8a361 to your computer and use it in GitHub Desktop.
LinkedIn Scripts
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
/* | |
Autosend Invites to anyone that shares X number of connections with you. | |
Way to use this script: | |
1. Save it as a bookmarklet | |
2. Go to 'People you may know' | |
3. Click on this bookmarklet. | |
4. Enter number of overlapping connections | |
5. Check your console | |
Tested on Google Chrome 37.0.2062.122 | |
*/ | |
cards = num_connections = prompt("How many connections?"); | |
num_connections = parseInt(num_connections); | |
$('.card').filter(function(index){ | |
common_connections = this.querySelector('.bt-incommon .glyph-text'); | |
return common_connections && common_connections.innerText > num_connections | |
}).map(function(){return this.querySelector('button[data-act=request]').click()}) |
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
/* | |
Pull all your LinkedIn Messages. | |
Way to use this script: | |
1. Save it as a bookmarklet | |
2. Go to your messages select which type: Messages, Sent, Invite, Archive, ... | |
3. Click on this bookmarklet. | |
4. Enter number of pages you want to pull starting from current page | |
5. Check your console | |
Tested on Google Chrome 37.0.2062.122 | |
*/ | |
var page_text = $('.page').text(); | |
var num_pages_pattern = /Page \d+ of (\d+)/; | |
var num_pages_match = page_text.match(num_pages_pattern); | |
var num_pages_str = num_pages_match[1]; | |
var ask_num_pages = prompt("How many pages do you want to pull? (Max: " + num_pages_str + ")"); | |
var num_pages = parseInt(ask_num_pages); | |
var messages = []; | |
var i = 0; | |
function getMessages(){ | |
var message_list = $('.message-item'); | |
Array.prototype.push.apply(messages, message_list); | |
i = i + 1; | |
if (i < num_pages){ | |
$('.next a')[0].click(); | |
setTimeout(getMessages, 2000); | |
} | |
else if (i == num_pages) { | |
parsed_messages = $.map(messages, parseElement); | |
console.log(JSON.stringify(parsed_messages)); | |
} | |
} | |
function extractText(domElement, querySelector){ | |
var elementFromQuerySelector = domElement.querySelector(querySelector); | |
var elementText = ''; | |
if (elementFromQuerySelector) { | |
elementText = elementFromQuerySelector.innerText; | |
if (elementText) { | |
elementText = elementText.trim(); | |
elementText = elementText.replace(/\s+/, ' '); | |
} | |
} | |
return elementText; | |
} | |
function parseElement(domElement){ | |
parsedElement = {}; | |
parsedElement['participants'] = extractText(domElement, '.participants'); | |
parsedElement['subject'] = extractText(domElement, '.subject'); | |
parsedElement['preview'] = extractText(domElement, '.preview'); | |
parsedElement['status'] = extractText(domElement, '.item-status'); | |
parsedElement['date'] = extractText(domElement, '.date'); | |
parsedElement['link'] = domElement.querySelector('.subject a').href; | |
return parsedElement; | |
} | |
getMessages(); |
I know there's an API. Though LinkedIn documentation is poor and there are numerous problems. I think the messages endpoint works but this is much easier to setup and work with.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Minified for bookmarklets:
Get Messages:
Mass LinkedIn Connect: