// ==UserScript== // @name Campfire Avatar // @namespace http://firefromthefly.com // @version 0.1 // @description Adds peoples avatars to the chatroom. // @match https://*.campfirenow.com/room/* // @copyright 2012+, You // ==/UserScript== var insertMessages = Campfire.Transcript.prototype.insertMessages; function addAvatar(author) { if (author.dataset.avatar) { var html = ['
'].join(''); author.insertAdjacentHTML('beforeend', html); } } Campfire.Transcript.prototype.insertMessages = function() { var messages = insertMessages.apply(this, arguments); messages.forEach(function(message) { if (message.kind === 'text') { addAvatar(message._author); } }); return messages; }; var style = document.createElement('style'); style.textContent = '.avatar{text-align:right;margin-top:5px;} .avatar img{border-radius:50%;box-shadow:0 1px 0 rgba(255, 255, 255, 0.5);}'; document.head.appendChild(style); [].slice.call(document.querySelectorAll('.text_message .author[data-avatar]')).forEach(function(el) { addAvatar(el); });