Skip to content

Instantly share code, notes, and snippets.

@lukaszkorecki
Created February 26, 2010 17:23
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 lukaszkorecki/315923 to your computer and use it in GitHub Desktop.
Save lukaszkorecki/315923 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name CampfireAvatars
// @namespace http://*campfirenow.com
// @description Inserts avatars of your homies
// @author Lukasz Korecki
// @include *.campfirenow.com/room*
// ==/userscript==
function add_avatars() {
// console.log("addind avatars");
$$('.author').each(
function(elem) {
if( ! elem.hasClassName("processed")) {
var login = elem.innerHTML.replace(" ","").replace(".","").toLowerCase();
if(avatars[login] != undefined) {
elem.insert(avatar_elem(avatars[login]));
}
elem.addClassName("processed");
}
});
}
// avatars list
// sooooo
// If the user's name is Testy Test he/she will appear in campfire as
// Test T.
// so
// "Test T.".replace(" ","").replace(".","").toLowerCase() == "testt"
var avatars = {
"testt" : "http://example.com/avatar.jpg"
};
function avatar_elem(url) {
return {
"before" : new Element("div").update(new Element("img", {"src" : url, "height" : "32px" } ))
};
}
add_avatars();
Campfire.Transcript.prototype.insertMessages_original_2 = Campfire.Transcript.prototype.insertMessages;
Campfire.Transcript.prototype.insertMessages = function() {
messages = this.insertMessages_original_2.apply(this, arguments);
add_avatars();
return messages;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment