cfg
5/15/2015 - 2:36 PM

Crudely extract custom emoji from a Slack web instance. Load the web interface for the Slack instance and paste this into the developer cons

Crudely extract custom emoji from a Slack web instance. Load the web interface for the Slack instance and paste this into the developer console.

jQuery('#main_emo_menu').click();
jQuery('button[aria-label=Custom]').click();

jQuery('.p-emoji_picker__list').css('min-height', '900px');
jQuery('.p-emoji_picker__list_container').parents('.ReactModal__Content.ReactModal__Content--after-open.popover').css('top', '0px');
jQuery('.p-emoji_picker__list_container').css('max-height', '100%');
jQuery('.p-emoji_picker__content .p-emoji_picker__input_container').hide();


var emoji = [];

jQuery('.p-emoji_picker__heading:contains("Custom")').parent().next('.p-emoji_picker__list').find('a.p-emoji_picker__list_item').each( function( ix, el ) {
	try {
		el = jQuery( el );
		var name = el.data('name').replace( /:/g, '' );
		var re = new RegExp( '\\b' + name + '\\b', 'g' );
		var aliases = el.data('names').replace( /:/g, '' ).replace( re, '' ).trim();
		var bg = el.find('.emoji').css('backgroundImage');
		if ( ! bg ) {
			return;
		}
		bg = bg.replace(/.*\s?url\([\'\"]?/, '').replace(/[\'\"]?\).*/, '');
		var extension = bg.match( /(\.\w+)$/ );
		if( !extension.length ) {
			console.log( 'Could not find extension for image %s', bg );
			extension = '.jpg';
		} else {
			extension = extension[0];
		}
		var out = name + extension;
		var curl = 'curl -o "' + out + '" "' + bg + '"';
		var obj = {
			name: name,
			aliases: aliases,
			source: bg,
			cmd: curl
		};

		emoji.push( obj );
	} catch(e) {
		debugger;
	}

} );
e = JSON.stringify( emoji );
// copy( e );
console.log('Run `copy(e);` to copy the Slack emoji to your clipboard');