Skip to content

Instantly share code, notes, and snippets.

@thisisrachelramos
Forked from dogeared/00_README
Last active April 6, 2021 08:33
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save thisisrachelramos/0a139a3f53d36b5b24359bcc99b39b3a to your computer and use it in GitHub Desktop.
Save thisisrachelramos/0a139a3f53d36b5b24359bcc99b39b3a to your computer and use it in GitHub Desktop.
Extracting / Exporting custom emoji from Slack
This builds off the excellent work of @lmarkus.
The scripts below can be used in conjunction with the Neutral Face Emoji Tools Google Chrome extension to (bulk!)
export emojis from one Slack team and import into another team:
https://chrome.google.com/webstore/detail/neutral-face-emoji-tools/anchoacphlfbdomdlomnbbfhcmcdmjej
Original work here: https://gist.github.com/lmarkus/8722f56baf8c47045621
Steps:
1) Run js in dev tools
2) Save json object in a txt file
3) Run bash script
4) Drag and drop all of the downloaded emojis in the bulk uploader
enabled through the chrome extension
#!/usr/bin/env bash
# Use:
# Make this file executable, and feed it the results from the Slack emoji URL dump. Files will be downloaded to `output`
# chmod +x downloadSlackEmojis.sh
# ./downloadSlackEmojis.sh emojiURLs.txt
#
# Note: This depends on the jq utility for parsing json from the command line - https://stedolan.github.io/jq/
mkdir -p output;
jq -r '.[] | "curl -s -o \"output/\(.name)\(.extension)\" \"\(.url)\""' $1 | \
while read -r line; do eval "$line"; done
# You can now drag and drop all the emoji files in the output folder to the Bulk Emoji Uploader space that you'll see on
# the https://<team>.slack.com/customize/emoji page if you've installed the chrome extension
# https://chrome.google.com/webstore/detail/neutral-face-emoji-tools/anchoacphlfbdomdlomnbbfhcmcdmjej
// Login to your team through the browser.
// Go to: https://<team name>.slack.com/customize/emoji
// Run this on the browser's dev tools javascript console
// This code scrolls to bottom of page to load all emojis
// (bc of virtualized list not revelaing all of the elements).
// Slow connections may wish to adjust the above factor past 2.5
var scrollTime = $(document).height() * 2.5
$("html, body").animate({ scrollTop: $(document).height() }, scrollTime);
var emojis = $('.emoji_row');
var numEmojis = emojis.size();
var pre = document.createElement('pre');
pre.append('[\n');
// After waiting for the scroll, grab url/name for each emoji
// and populate a json object that will appear at the bottom of the page
window.setTimeout(function() {
emojis.each(function(index) {
var url = $(this).find('td:nth-child(1) span').attr('data-original');
var extension = url.substring(url.lastIndexOf('.'));
var name = $(this).find('td:nth-child(2)').html().replace(/:|\s/g, '');
pre.append(JSON.stringify({ name: name, extension: extension, url: url }));
if (index == (numEmojis - 1)) {
pre.append('\n]');
} else {
pre.append(',\n');
}
});
console.log(pre);
}, scrollTime + 1000);
// Now, at the bottom of the page you'll see the json representation of all the emoji data
// copy and paste the json into a file (named "emojiURLs.txt" in "downloadSlackEmojis.sh" instructions)
// and use with downloadSlackEmojis.sh
@lmarkus
Copy link

lmarkus commented Feb 2, 2019

UPDATE for 2019:
Hi folks... Author of the original gist here.
There's a much easier way to get the emoji list. I've updated the original gist, and added a Readme with the new approach.
( https://gist.github.com/lmarkus/8722f56baf8c47045621 )

Thanks to all the folks that have contributed to enhancing this solution over the years. ❤️ OpenSource!

Enjoy your emoji, and give me a follow on twitter @lennymarkus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment