Skip to content

Instantly share code, notes, and snippets.

@xeniatay
Last active July 1, 2019 16:25
Show Gist options
  • Save xeniatay/b2a5cb43e2518ce3b5924660d0961304 to your computer and use it in GitHub Desktop.
Save xeniatay/b2a5cb43e2518ce3b5924660d0961304 to your computer and use it in GitHub Desktop.
Bulk export custom emoji from Slack

This builds off the excellent work of @lmarkus, @dogeared, @itsrachelle, and @JPablomr.

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, https://gist.github.com/itsrachelle/0a139a3f53d36b5b24359bcc99b39b3a.

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.
*/
// Track the inside container's position
var scrollPosition = $('.c-scrollbar__hider')[0].scrollTop;
// Bump this higher if it's stopping mid-list.
var SLEEP_TIME = 750;
while(true) {
// We're not sure how big the container is as it's loaded dynamically
// So we scroll in increments of 1000
var newScrollPosition = $('.c-scrollbar__hider')[0].scrollTop += 1000;
// We know we've hit the bottom when the position stops changing
if (newScrollPosition == scrollPosition) {
break;
}
// Otherwise let's track the current position and keep going
scrollPosition = newScrollPosition;
// Sleep so the page can load the new emojis
await sleep(SLEEP_TIME);
}
/* This code extracts all the emoji data into the following format:
[
{
name,
url,
extension,
},
]
* This emoji data is then automatically copied onto your clipboard.
*/
// Set the row container to a ridiculously large height, so that all the emojis
// are visible in the document.
document.getElementsByClassName('c-table_view_all_rows_container')[0].style.height = '100000px'
var emojis = document.getElementsByClassName('p-customize_emoji_list__image')
var extract = []
for (var i = 0; i < emojis.length; i++) {
var image = emojis[i]
extract.push({
name: image.alt,
extension: `.${image.src.split('.').pop()}`,
url: image.src,
})
}
console.log(extract)
copy(extract)
// Now, paste the contents of your clipboard into a file (named "emojiUrls.txt")
// Use with downloadSlackEmojis.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment