Skip to content

Instantly share code, notes, and snippets.

@BrettBukowski
Created July 16, 2014 17:48
Show Gist options
  • Save BrettBukowski/599b03d4acef7f9d87cb to your computer and use it in GitHub Desktop.
Save BrettBukowski/599b03d4acef7f9d87cb to your computer and use it in GitHub Desktop.
dotjs Slack customization: add avatars to siderail
// - Adds avatars to Slack's members siderail.
// - Hides inactive members.
// Maintain a cache of avatars when moving
// between channels.
var avatars = {};
setInterval(function () {
$('#direct_messages_header').text('people');
$('#im_list_more').hide();
$('#im-list .slackbot_icon').closest('li').remove();
$('#im-list .presence.away').closest('li').hide();
$('#im-list .presence.active').each(function () {
var userStatus = $(this),
link = userStatus.closest('a'),
id = link.attr('data-member-id'),
// Get the user's avatar from the channel's message stream,
// if that user has posted.
user = $('#msgs_div a[data-member-id="' + id + '"]');
if (user.length) {
avatars[id] = user.attr('style');
}
if (userStatus.attr('style')) return;
userStatus.attr('style', avatars[id]).show()
.css({
height: '48px',
width: '48px',
'-webkit-transform': 'scale(.5)',
'-moz-transform': 'scale(.5)',
'-ms-transform': 'scale(.5)',
'transform': 'scale(.5)',
position: 'relative',
top: '-20px',
'margin-left': '-12px',
'border-radius': '50%'
}).closest('li').css('margin', '4px 0');
});
}, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment