Last active
January 28, 2016 20:07
-
-
Save nathansmith/dc73aa7d3b6f998eb38e to your computer and use it in GitHub Desktop.
This function can be used to pre-check (for removal) all recruiters in your LinkedIn connections list.
This file contains hidden or 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
/* | |
This function can be used to pre-check (for removal) | |
all recruiters in your LinkedIn connections list. | |
It excludes recruiters that are also colleagues, so | |
you don't accidentally get any false positivies. | |
It doesn't actually do any deletion, just makes the | |
connections list focused solely on recruiters. The | |
deletion itself is up to you. | |
Note: You should scroll down to the bottom of your | |
connections list until they have all lazy-loaded | |
into the DOM. Then run this snippet… | |
*/ | |
(function ($) { | |
$('.contact-item-view').each(function () { | |
var row = $(this) | |
var checkbox = row.find('input[type="checkbox"]') | |
var tagListText = row.find('.tag-list').text() | |
var isColleague = tagListText.match(/colleague/gi) | |
var title = row.find('.title').text() | |
var isRecruiter = | |
title.match(/account executive|account manager|business development manager|hiring|recruit|talent/gi) | |
if (isRecruiter && !isColleague) { | |
checkbox.prop('checked', true) | |
} else { | |
row.hide() | |
} | |
}) | |
})(this.jQuery) |
This file contains hidden or 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
/* | |
After running the above script, to actually | |
do a batch delete, use this snippet… | |
*/ | |
(function ($) { | |
$('.contact-item-view:visible').each(function () { | |
var row = $(this) | |
var checkbox = row.find('input[type="checkbox"]') | |
var isChecked = checkbox.prop('checked') | |
// Get contact's ID. | |
var id = | |
row | |
.find('a[href*="/contacts/view?id="]') | |
.attr('href') | |
.split('?id=')[1] | |
.split('&')[0] | |
// Build the URL. | |
var url = [ | |
'/contacts/api/contacts/', | |
id, | |
'/' | |
].join('') | |
// Is it checked? | |
if (isChecked) { | |
// Send the request. | |
$.ajax({ | |
url: url, | |
type: 'DELETE' | |
}) | |
} | |
}) | |
})(this.jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment