Skip to content

Instantly share code, notes, and snippets.

@nealey
Last active May 25, 2023 23:09
Show Gist options
  • Save nealey/5549ec14a182bc59510dd76f62e2bc64 to your computer and use it in GitHub Desktop.
Save nealey/5549ec14a182bc59510dd76f62e2bc64 to your computer and use it in GitHub Desktop.
Bulk delete every custom emoji in Slack
//
// 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
@d0x2f
Copy link

d0x2f commented Jul 20, 2020

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