Skip to content

Instantly share code, notes, and snippets.

@nopfor
Last active October 9, 2019 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nopfor/6a6abf04f52464eec71603b747ffc49a to your computer and use it in GitHub Desktop.
Save nopfor/6a6abf04f52464eec71603b747ffc49a to your computer and use it in GitHub Desktop.
Download Custom Slack Emojis

Download Emojis from Slack Web Client

Use the emoji.list Slack API to download the custom emojis list from Slack. Due to the CORS policy on emoji endpoints, it is not possible to download the emojis from the Slack web client using JavaScript. Emoji URLs do not require authentication, however, so they can be downloaded outside the browser.

Get CSV

Run download.js in your browser to dowload a CSV containing filename,url for each custom emoji.

Download

Run download.sh to download files from the CSV and save them to the current directory.

On Windows, run download.ps1 in the same folder as the CSV.

// grab slack custom emoji URLs and save as CSV
var emojis = {};
// get auth token for API request
var authToken = JSON.parse(localStorage.localConfig_v2).teams[slackDebug.activeTeamId].token;
// setup request
var formData = new FormData();
formData.append('token', authToken);
(async () => {
const rawResponse = await fetch('/api/emoji.list', {
method: 'POST',
body: formData
});
const emojisApi = await rawResponse.json();
emojis = emojisApi.emoji;
// generate CSV
var csvContent = 'data:text/csv;charset=utf-8,';
for (const [name, url] of Object.entries(emojis)) {
if (typeof url === 'string' && url.startsWith('http')) {
var filename = name.replace("'", "\\'") + '.' + url.split('.').pop();
csvContent += filename + ',' + url + '\n';
}
}
// download csv
var encodedUri = encodeURI(csvContent);
var csvDownloader = document.createElement('a');
csvDownloader.href = encodedUri;
csvDownloader.download = 'emojis.csv';
document.body.appendChild(csvDownloader);
csvDownloader.click();
document.body.removeChild(csvDownloader);
})();
$emojis = Import-Csv -Path .\emojis.csv -Header 'Name','Url'
foreach ($emoji in $emojis) {
Invoke-WebRequest -Uri $emoji.Url -OutFile $emoji.Name
}
for emoji_line in $(cat emojis.csv); do
name=$(echo "$emoji_line" | cut -d, -f1)
url=$(echo "$emoji_line" | cut -d, -f2)
wget -O "$name" "$url"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment