LinkedIn is a valuable resource, but sometimes it sucks. One of those times is when you want to delete messages. You have to select each message one by one. It takes about 4 "clicks" to successfully delete a message.
This script should help. Since LI requires you to perform multiple steps, I decided to automate it for you. Once you initiate the script, it will run every second. If a message has the ability to be deleted, it will be. If not, it will be archived. Some "InMail" messages cannot be deleted on the web app. This script should work as long as LI doesn't change their page layout or element names, which will happen eventually.
Last tested: April, 29, 2020
- Since we use word matching, make sure to update the
ARCHIVE
andDELETE
vars to your language. - Some people only want to Archive and not Delete the messages, select this by updating the
METHOD
var. - BEFORE pasting the script, make sure you've manually scrolled as far as you can so more messages are loaded, and you've clicked on one of the messages so the message contant pane is visible.
- You need to stay on the screen until it completes. It takes about 1 second per message. There is the possibility to speed it up, but this is the time that I found let each request be successful. Also, deleting takes a bit longer.
- It can only delete messages that are in the current view. You have two options here:
- Before pasting the script, scroll down your message list to reveal all messages
- Run the script till the page is empty, then refresh and run it again.
- Personally, I found that any more than about 200 messages caused the page to run super slow.
- Go to the messages screen: LinkedIn Messages
- Open up your Chrome Console*
- Paste the following in the console
* if you are not sure what this is, then this script is not for you.
(function() {
// Set Your Language Here
const ARCHIVE = "Archive";
const DELETE = "Delete";
// Would you like to Archive them or Delete messages?
// Archive = 1, Delete = 2
const METHOD = 1;
const goneFn = () => {
const timer = setInterval(() => {
const dropdown = document.querySelector('.msg-thread-actions__control');
if (!dropdown) return clearInterval(timer);
dropdown.click(); // Opens Up Menu
const dropdownItems = document.querySelectorAll('.msg-thread-actions__dropdown-option');
for (let i = 0; i < dropdownItems.length; i++) {
let txt = dropdownItems[i].textContent.trim();
// Delete Items
if (txt === DELETE && METHOD === 2){
dropdownItems[i].click();
setTimeout(() => {
const frame = document.querySelector('.msg-modal-delete-convo');
const delBtn = frame.querySelector('.artdeco-button--primary');
delBtn.click();
}, 500);
}
// Archive Them Instead
if (txt === ARCHIVE && METHOD === 1) {
dropdownItems[i].click();
}
}
}, 1000);
};
goneFn();
})();