Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Jaballadares/95d0dfa93c1ca0147c2210261beb1afa to your computer and use it in GitHub Desktop.
Save Jaballadares/95d0dfa93c1ca0147c2210261beb1afa to your computer and use it in GitHub Desktop.
LinkedIn Scripts
/*
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()})
/*
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment