Last active
January 15, 2016 13:07
-
-
Save nathansmith/a7d32d573efeef392370 to your computer and use it in GitHub Desktop.
JS snippet to empty all messages from LinkedIn's UI.
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 empty your | |
LinkedIn inbox. You should first scroll | |
to the bottom of the list, so that it | |
lazy-loads all of your messages into | |
the DOM at once. Then run this… | |
*/ | |
// Closure. | |
(function ($) { | |
// Extract security token. | |
var token = | |
$('a[href*="csrfToken="]') | |
.attr('href') | |
.split('csrfToken=')[1] | |
.split('&')[0] | |
// Loop through delete links. | |
$('.delete-action').each(function () { | |
// Get unique message ID. | |
var id = | |
$(this) | |
.closest('.thread-preview') | |
.find('[data-id]') | |
.attr('data-id') | |
// Build URL. | |
var url = [ | |
'/messaging/conversations/', | |
id, | |
'?csrfToken=', | |
token | |
].join('') | |
// Send the request. | |
$.ajax({ | |
url: url, | |
type: 'DELETE' | |
}) | |
}) | |
// Pass jQuery into scope. | |
})(this.jQuery) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment