Campfire Bot
1 2 // ==UserScript== 3 // @name Campfire Bot 4 // @namespace http://d.hatena.ne.jp/youpy/ 5 // @description bot on campfire 6 // @include http://*.campfirenow.com/room/* 7 // ==/UserScript== 8 9 (function (){ 10 getLastMessage = function() { 11 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); 12 return div.snapshotItem(div.snapshotLength - 1).innerHTML; 13 14 } 15 16 window.setInterval( 17 function() { 18 last_message = getLastMessage(); 19 if(this.last_message != (sorted = last_message.split('').sort().join(''))) { 20 this.last_message = sorted; 21 if(last_message.match(/^\//)) { 22 switch(last_message) { 23 case '/now': 24 this.chat.speaker.speak(new Date().toString()); 25 break; 26 } 27 } else { 28 this.chat.speaker.speak(last_message.split('').reverse().join('')); 29 } 30 31 } 32 }, 3000); 33 })();
residents at here