Skip to content

Instantly share code, notes, and snippets.

@dylanegan
Created March 20, 2011 19:36
Show Gist options
  • Save dylanegan/878593 to your computer and use it in GitHub Desktop.
Save dylanegan/878593 to your computer and use it in GitHub Desktop.
caveatPatchor.js
var rebeccaBlack = true;
if (rebeccaBlack) {
Campfire.RebeccaBlack = Class.create({
initialize: function(chat) {
this.chat = chat;
var messages = this.chat.transcript.messages;
for (var i = 0; i < messages.length; i++) {
this.friday(messages[i]);
}
},
friday: function(message, autoplay) {
var autoplay = autoplay || "";
if (message.bodyElement().innerText.match(/^\/friday$/)) {
var audio = document.createElement('audio');
audio.src = "http://dylanegan.com/friday.mp3";
audio.autoplay = autoplay;
document.body.insertBefore(audio);
message.bodyElement().innerHTML = '<img src="http://29.media.tumblr.com/tumblr_li0l8ue1BV1qe11aoo1_250.gif">';
}⋅
},
onMessagesInsertedBeforeDisplay: function(messages) {
for (var i = 0; i < messages.length; i++) {
this.friday(messages[i], "autoplay");
}⋅
}
});
Campfire.Responders.push("RebeccaBlack");
window.chat.installPropaneResponder("RebeccaBlack", "rebeccablack");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment