Skip to content

Instantly share code, notes, and snippets.

@rlemon
Last active December 11, 2015 23:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rlemon/4676005 to your computer and use it in GitHub Desktop.
Save rlemon/4676005 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name MOUSTACHE CHAT
// @author Robert Lemon
// @version 0.1
// @namespace http://rlemon.com
// @description Makes the chat all moustachy
// @include http://chat.stackexchange.com/rooms/*
// @include http://chat.stackoverflow.com/rooms/*
// ==/UserScript==
(function() {
var elm = document.createElement('script');
elm.src = 'http://lemonmeme.com/moustache.js';
document.body.appendChild(elm);
}());
/***************************************
* http://lemonmeme.com/moustache.js *
***************************************/
function gravatarUrl(a,e,f){
return"!"==e.charAt(0)?(a=e.substr(1),imgurProfileImage.test(a)&&(e=/\?/.test(a)?"&":"?",a+=e+"g&s="+legalImgurSizeAtLeast(f)),a):"http://mustachify.me/?src=http://lemonmeme.com/moustache.php?img="+e;
}
function init() {
$('.avatar img').each(function() {
var tests = $(this).closest('.user-container').attr('class').match(/user-(\d+)/g);
if( tests ) {
var id = tests[0].split('-')[1];
this.src = gravatarUrl(id,CHAT.user(id).email_hash,128)
}
});
}
setTimeout(init, 1000); // funky bug if I don't wait for the chat to init. I'm too lazy to think of another alternative.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment