Skip to content

Instantly share code, notes, and snippets.

@heathdutton
Last active November 9, 2016 02:38
Show Gist options
  • Select an option

  • Save heathdutton/1abae411ccad3d129688 to your computer and use it in GitHub Desktop.

Select an option

Save heathdutton/1abae411ccad3d129688 to your computer and use it in GitHub Desktop.
Apparently, JavaScript CAN make you new friends.
/**
* Linkedin auto-connect thingy.
*
* Step 1) Log in to Linkedin and go to https://www.linkedin.com/people/pymk
* (This is the "People You May Know page")
* Step 2) Open your browser console and run this javascript.
*/
(function($) {
var processedCards = [];
var lih = function(){
// Remove cards that require email
$('ul.people-cards-list li.card.guest').remove();
// Get the other buttons that have loaded
var buttons = $('ul.people-cards-list li.card:not(.guest) button.bt-request-buffed.buffed-blue-bkg-1:not(.processed)');
if (buttons.length){
// Scroll down to the last one to cause ajax loading of the next set of buttons.
$('html body').stop().animate({
scrollTop: buttons.last().offset().top
}, 3000);
// Set random intervals for clicking the buttons.
var timer = 0;
buttons.addClass('processed');
buttons.each(function(){
var id = $(this).parent().find('button.bt-incommon').attr('data-memberid'),
name = $(this).parent().find('.profile-info .name-wrapper .name').clone().find('span').remove().end().text();
if (typeof(processedCards[id]) != 'undefined'){
// Already clicked this person
$(this).parent().parent().parent().remove();
console.log('Already connected: ' + name);
} else {
// New person, goodie...
processedCards[id] = true;
var rand = Math.random() * (5000 - 1000) + 1000,
t = $(this);
timer += rand;
setTimeout(function(){
console.log('Connecting: ' + name);
t.trigger('click');
}, timer);
}
});
}
}
setInterval(function(){ lih(); }, 6000);
lih();
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment