Created
May 7, 2020 13:11
-
-
Save debanshu/78fc55143fc52a0065aff5b82286f662 to your computer and use it in GitHub Desktop.
Slack Email Files Deleter
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
| /** | |
| Since I had forwarded my emails to my slack email, | |
| it started to fill up my slackbot channel. | |
| This script is a very crude approach to deleting all the email files forwarded to me on slackbot. | |
| Required since there's no bulk delete on Slack yet. | |
| Needs the new Slack desktop UI to work. | |
| Only runs in the currently active channel/conversation | |
| DISCLAIMER: Deletion of Slack Messages is permanent. | |
| Please be careful of using this script. I take no responsibility for accidentally lost messages, | |
| and I may not be updating the script unless I need to run it again. | |
| **/ | |
| // function to delete the last email/attchement/file in the current channel | |
| function deleteMsg() { | |
| setTimeout(() => { | |
| document.querySelector(".p-message_pane_message__message--last [data-qa='more_file_actions']").click(); | |
| setTimeout(() => { | |
| document.querySelector("[data-qa='delete_file']").click(); | |
| setTimeout(() => document.querySelector("[data-qa='dialog_go']").click(), 0); | |
| }, 0); | |
| }, 0); | |
| } | |
| // schedule at every interval_seconds - tune based on your system/network speed; since this just emulates an actual browser interaction | |
| const interval_seconds = 2; | |
| const interval_id = setInterval(deleteMsg, interval_seconds*1000) | |
| // clear interval_id to stop - PLEASE USE BEFORE YOU SWITCH CHANNELS/CONVERSATIONS TO AVOID LOSING MESSAGES ACCIDENTALLY | |
| clearInterval(interval_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment