Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Last active January 15, 2016 13:07
Show Gist options
  • Save nathansmith/a7d32d573efeef392370 to your computer and use it in GitHub Desktop.
Save nathansmith/a7d32d573efeef392370 to your computer and use it in GitHub Desktop.
JS snippet to empty all messages from LinkedIn's UI.
/*
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