Rate this script:  I Love it  /   I Hate it

Campfire Bot


Code


// ==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);
})();
 

 

 
Campfire Bot scripts | Campfire Bot snippet | Campfire Bot example | Campfire Bot tutorial | Campfire Bot code