Skip to content

Instantly share code, notes, and snippets.

@mdunham
Created January 4, 2018 04:07
Show Gist options
  • Save mdunham/c9be76ff0fb24da355a723dd43e716cd to your computer and use it in GitHub Desktop.
Save mdunham/c9be76ff0fb24da355a723dd43e716cd to your computer and use it in GitHub Desktop.
I got tired of manually deleting messages on LinkedIn so I created this little gem. It adds a delete all messages button for your LinkedIn inbox. Just like my delete all Facebook messages script. :-) Enjoy!
/**
* Delete all LinkedIn Messages Bookmark
* Create a new bookmark in your bookmark bar named: Clean LinkedIn Inbox
* Set the url of the bookmark to everything the code below on line 7
*/
javascript:(function(b,c){var d=0,f=function(){var k=b('a[href^="/messaging/thread/"]',!0);k[d]?(k[d].click(),setTimeout(g,c)):(console.log('All Done :)'),location.reload())},g=function(){var k=h,l=b('a[title="Show conversation details"]');l?l.click():(d++,k=f),setTimeout(()=>k(),c)},h=function(){var k=b('[data-control-name="clear_conversation"]');k&&k.click(),setTimeout(j,c)},j=function(){var k=b('[data-control-name="clear_conversation_confirm"]');k&&k.click(),setTimeout(f,c)};f()})(function(b,c){return c?document.querySelectorAll(b):document.querySelector(b)},1000);
// Now you can navigate to your linkedin.com inbox and then
// click your new bookmark to begin cleaning your inbox.
// Want to run it with-out a bookmark?
// The code below is the unminified version of the bookmark url.
/**
* This is the all of the code that runs when you click the bookmark.
* Alternatively, you could copy the below code and run in your developer console.
* Just make sure you run it while on your LinkedIn inbox
*/
(function($, speed) {
var
i = 0,
nxt = function() {
var e = $('a[href^="/messaging/thread/"]', true);
if (e[i]) { e[i].click(); setTimeout(delit, speed); }
else { console.log('All Done :)'); location.reload(); }
},
delit = function() {
var n = delitBro,
e = $('a[title="Show conversation details"]');
if (e) e.click();
else { i++; n = nxt; }
setTimeout(() => n(), speed);
},
delitBro = function() {
var e = $('[data-control-name="clear_conversation"]');
if (e) e.click();
setTimeout(delitNOW, speed);
},
delitNOW = function() {
var e = $('[data-control-name="clear_conversation_confirm"]');
if (e) e.click();
setTimeout(nxt, speed);
};
nxt();
})(function(s, a) { return (a) ? document.querySelectorAll(s) : document.querySelector(s) }, 1000);
@asifnauman125
Copy link

How can I used this script?

@DaveMitten
Copy link

How can I used this script?

It literally says it in the file in the comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment