DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Campfire Bot

02.17.2006
| 7623 views |
  • submit to reddit
        
// ==UserScript==
// @name Campfire Bot
// @namespace http://d.hatena.ne.jp/youpy/
// @description bot on campfire
// @include http://*.campfirenow.com/room/*
// ==/UserScript==

(function (){
    getLastMessage = function() {
	div = document.evaluate("//tr[contains(@class,'text_message') and not(contains(@class,'you'))]/td[@class='body']/div", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
	return div.snapshotItem(div.snapshotLength - 1).innerHTML;
	
    }
    
    window.setInterval(
		       function() {
			   last_message = getLastMessage();
			   if(this.last_message != (sorted = last_message.split('').sort().join(''))) {
			       this.last_message = sorted;
			       if(last_message.match(/^\//)) {
				   switch(last_message) {
				   case '/now':
				       this.chat.speaker.speak(new Date().toString());
				       break;
				   }
			       } else  {
				   this.chat.speaker.speak(last_message.split('').reverse().join(''));
			       }

			   }
		       }, 3000);
})();

residents at <a href="http://youpy.campfirenow.com/4a168">here</a>