Skip to content

Instantly share code, notes, and snippets.

@bhagatparwinder
Forked from timwco/delete.md
Created June 14, 2022 19:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bhagatparwinder/2668ed152823558129782b0721dac61c to your computer and use it in GitHub Desktop.
Save bhagatparwinder/2668ed152823558129782b0721dac61c to your computer and use it in GitHub Desktop.
LinkedIn: Delete Messages (June 2022)

What

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 happens often.

Last tested & verified working on: June, 10, 2022

Special Thanks to @noncent for the updated script.

* if you are not sure what this is, then this script is not for you.

/**
 * Warning - this script is made for education purpose only and must be run, executed on your own risk.
 * Author is not responsible for anything.
 * 
 * Delete all your old notifications from Linkedin
 * 
 * Step 1 - open link https://www.linkedin.com/notifications/
 * Step 2 - open browsers console panel by right click and inspect
 * Step 3 - go to console tab and paste script
 * Step 4 - Hit the enter
 */
[...document.querySelectorAll('[type="trash-icon"]')].map(x => x.click());

/**
 * Warning - this script is made for education purpose only and must be run, executed on your own risk.
 * Author is not responsible for anything.
 * 
 * URL - https://www.linkedin.com/messaging/thread/new/
 *
 * Delete all your old & archive messages from Linkedin
 *
 * Step 1 - open link https://www.linkedin.com/messaging/thread/new/
 * Step 2 - open browsers console panel by right click and inspect
 * Step 3 - go to console tab and paste script
 * Step 4 - Hit the enter and click yes when prompt for delete
 */
setInterval(function () {
    [...document.querySelectorAll(".msg-selectable-entity__checkbox-circle")].map(
        function (x) {
            x.click();
            setTimeout(function () {
                [...document.querySelectorAll('[type="trash-icon"]')].map(a => a.click());
            }, 1000);
        })
}, 3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment