Last active
May 25, 2023 23:09
-
-
Save nealey/5549ec14a182bc59510dd76f62e2bc64 to your computer and use it in GitHub Desktop.
Bulk delete every custom emoji in Slack
This file contains 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
// | |
// I just found out that we have a bunch of NSFW emoji in our bulk-imported set of >4000 emoji. | |
// Rather than weed them out, I want to start with a blank slate. This code does that. | |
// | |
// Navigate to your "Custom Emoji" page, the one with all the delete buttons. | |
// Delete one of them and acknowledge that it's going away forever. | |
// Then open the JavaScript console and paste this in. | |
// | |
// At some point your JavaScript console will start spewing errors. | |
// Reload the Emoji page, delete one emoji by hand again, and paste this in again to resume. | |
// | |
// Thanks to slifty for a June 2020 update! | |
function killer() { | |
let emojirows = document.getElementsByClassName("c-virtual_list__item"); | |
for (let e of emojirows) { | |
let rem = e.querySelector("button [emoji-type=enabled]"); | |
rem.click(); | |
let confirmButton = document.getElementsByClassName("c-button--danger")[0].click(); | |
return; | |
} | |
} | |
ki = setInterval(killer, 1500); // they rate limit now |
@slifty radical! Thanks, I've gone ahead and blithely replaced my code with yours.
Reader: if you're reading this because it didn't work, take a look at the revision history and let me know what the next revision needs to be :)
I had some issues where it would try to click the confirm button before it actually showed.
I had some success with this:
let intervalId;
intervalId = setInterval(() => {
let deleteButton = document.querySelector("button [emoji-type=enabled]");
if (!deleteButton) {
clearInterval(intervalId);
console.log("Bulk emoji delete completed!");
} else {
deleteButton.click();
setTimeout(() => document.getElementsByClassName("c-button--danger")[0].click(), 300);
}
}, 2000);
I had ~600 emojis to clear and this deletes faster than the list can load, so I often had to refresh and run it again.
It didn't take long though.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Something may have changed, but this worked for me (for a few at a time)