Created
February 26, 2010 17:23
-
-
Save lukaszkorecki/315923 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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