// ==UserScript== // @name Shoutbox CC // @namespace http://blog.thedt.net // @description shoutbox Custom Commands // @include *msghelp.net/shoutbox.php* // ==/UserScript== //made by -dt- , darktempler@gmail.com //Command list mod by Plik, thatspollacks.net /*IF YOU ALREADY HAVE SHOUTBOX CUSTOM COMMANDS INSTALLED THEN SAVE YOUR COMMANDS BEFORE YOU INSTALL THIS SCRIPT, THEN REPLACE THE COMMANDS IN THIS SCRIPT WITH YOUR COMMANDS DON'T DO A JA :P */ var commands = new Array(); var gC = new Array(); //now commands are simpleish to set up // all you have to do is create a new array element with what function to call eg //commands['moo'] = function(){post('moo');} //makes a function which when you type /moo sends moo to the server as the shout, you can also use post in downloadSite function as used in /np command below //and i also pass anything recived after the command eg /moo mahahaha would be passed in the function eg to handle it you could use //commands['moo'] = function(text){post('mooo '+ text);} //for the now playing script you dont have to edit this just do.... /set npsite locationoffile .... in the shoutbox commands['np'] = function(){ var site = GM_getValue('npsite') || 'http://random.thedt.net/scripts/test.txt';downloadSite(site, function(details){var format = GM_getValue('npstyle') || '[b]%song%[/b]';var song = format.replace('%song%',details.responseText); post(song)} )} //poor mans np //commands['np'] = function(){ downloadSite('http://www.leejeffery.co.uk/web2msn.php?username=madman',function(details){post('Now Playing: ' + details.responseText.substr(details.responseText.indexOf("PSM = ") + 6))});} commands['psm'] = function(uname){uname = uname.replace(' ', ''); downloadSite("http://www.web2messenger.com/status/" + uname + ".xml",function(details){ var xxx = new XML(details.responseText.replace('',''));if(xxx.name().localName == "error"){post("[b]Error[/b]: " + uname + " doesnt have a Web2MSN account");return;}post(uname + "'s psm: " + xxx.psm); });} commands['dt'] = function(){ post('/me < dt'); } commands['setcc'] = set; commands['moo'] = function(){post("/me randomly starts mooing at the peoples in the box...")} commands['kill'] = function(person){post("/me kills " + person);} commands['dns'] = function(site){x = site;downloadSite('http://thedt.net/cc/dns.php?host='+site,function(details){post('/me dns resolved '+x +' to ' +details.responseText)});} commands['objslap'] = function(blah){arr = blah.split(' '); var person = arr[0]; arr[0] = ""; var item = arr.join(' '); post('/me slaps '+ person +' around a bit with '+ item);} commands['wave'] = function(ipt){post("/me :wave:'s at " + ipt);} commands['total'] = get_total_time_spent; commands['web2msn'] = function(uname){ uname = uname.replace(' ', ''); downloadSite("http://www.web2messenger.com/status/" + uname + ".xml" ,function(details){ var xxx = new XML(details.responseText.replace('','')); if(xxx.name().localName == "error"){ post("[b]Web2MSN[/b]: " + xxx); return; } var status = String(xxx.status); var name = String(xxx.displayname); var customStatus = String(xxx.displayname).match(/\{(.*)\}$/); if(customStatus){ name = name.replace(/\{(.*)\}$/,""); status = customStatus[1]; } //the dot thing var sp = String.fromCharCode(183); var plus_colors = new Array( "FFFFFF","000000","00007F","009300","FF0000","7F0000","9C009C","FC7F00","FFFF00","00FC00","009393","00FFFF","0000FF","FF00FF","7F7F7F","D2D2D2","E7E6E4","CFCDD0","FFDEA4","FFAEB9","FFA8FF","B4B4FC","BAFBE5","C1FFA3","FAFDA2","B6B4B7","A2A0A1","F9C152","FF6D66","FF62FF","6C6CFF","68FFC3","8EFF67","F9FF57","858482","6E6D7B","FFA01E","F92611","FF20FF","202BFF","1EFFA5","60F913","FFF813","5E6464","4B494C","D98812","EB0505","DE00DE","0000D3","03CC88","59D80D","D4C804","333335","18171C","944E00","9B0008","980299","01038C","01885F","389600","9A9E15","473400","4D0000","5F0162","000047","06502F","1C5300","544D05"); var usesNewColor = name.match(/\[c=[0-9]{1,2}\](.*?)\[\/c\]/g); if(usesNewColor){ var color; for(var i=0;i; Format is optional, and uses the php time format. commands['noparse'] = function(text){noparsePost(text);} commands['exit'] = function(text){window.close();} commands['mimic'] = mimic //example of a global command (excucutes on all non functions) gC[gC.length] = function(text){return text.replace(':\\',':-/');} gC[gC.length] = function(text){var time = timeFunc(); return text.replace(/\(!T\)/g,time);} gC[gC.length] = function(text){var date = dateFunc(); return text.replace(/\(!D\)/g,date);} //auto convert * to /me if its at the start gC[gC.length] = function(text){return text.replace(/^\*/,'/me ');} //(!PEOPLE) gC[gC.length] = function(text){return text.replace(/\(!PEOPLE\)/i,getOnlinePeople())} gC[gC.length] = function(text){return text.replace(/^\/q /i,"/quote ")} //find our textbox with a good ole xpath. var textbox = document.evaluate('//input[@type="text"]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; var form = document.evaluate('//form[@name="msgform"]',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; //ah replace the checkName function with our own little one :P hookSubmit(); textbox.addEventListener("keypress", keyUp, false); textbox.addEventListener("blur", function (e){ hideCommandWind(); }, true); var cwContainer; var suggestCmd = false; var contShown = false; //This array is used for the list var cmds = new Array(); cmds[cmds.length] = "me"; cmds[cmds.length] = "quote"; cmds[cmds.length] = "slap"; cmds[cmds.length] = "theme"; cmds[cmds.length] = "shout"; cmds[cmds.length] = "ls"; cmds[cmds.length] = "setppp"; cmds[cmds.length] = "text"; cmds[cmds.length] = "set"; for(x in commands){ cmds[cmds.length] = x; } cmds = cmds.sort(); makeCommandWind(); //start functions here... function parseToBbcode(str){ str = str.replace(/(.+?)<\/b>/,"[b]$1[/b]"); str = str.replace(/(.+?)<\/i>/,"[i]$1[/i]"); str = str.replace(/(.+?)<\/u>/,"[u]$1[/u]"); str = str.replace(/(.+?)<\/strike>/,"[s]$1[/s]"); str = str.replace(//,"[img]$1[/img]"); str = str.replace(/\[img\]images\/smilies\/(.+?)\[\/img\]/,"[img]$1[/img]"); str = str.replace(/(.+?)<\/span>/,"[color=$1]$2[/color]"); return str; } function mimic(text){ var lastbox = document.evaluate('//body/table[1]/tbody/tr/td/table/tbody/tr[last()]/td',document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML //split the first part then replace it :P if only javascript replace accepted limits. var me = lastbox.match(/\* (.+?)<\/a><\/b>(.+)/i); if(me){ lastbox = "/me " + parseToBbcode(me[3]); }else{ lrep = lastbox.split('>',1) + '>'; lastbox = lastbox.replace(lrep,''); //if they own the post remove the edit. lastbox = lastbox.replace(/\[edit\]<\/span><\/a>/,''); lastbox = parseToBbcode(lastbox); } post(lastbox); } function dateFunc(){ var time = new Date(); dateString = time.getDay() + '/' + time.getMonth() + '/' + time.getFullYear(); return dateString; } function timeFunc(fmat){ if(!fmat) fmat = GM_getValue("timeformat", "H:i:s"); if(fmat == "") fmat = GM_getValue("timeformat", "H:i:s"); if(fmat == " ") fmat = GM_getValue("timeformat", "H:i:s"); var time = new Date(); var a, A, H, h, g; var G = time.getHours(); var i = time.getMinutes(); var s = time.getSeconds(); if(G >= 12) { g = G - 12; a = "pm"; } else { g = G; a = "am"; } if(g == 0) g = 12; if(G < 10) H = "0" + G; else H = G; if(g < 10) h = "0" + g; else h = g; if(i < 10) i = "0" + i; if(s < 10) s = "0" + s; A = a.toUpperCase(); var opstr = fmat.replace(/([^\\]|)a/g, "$1"+a); opstr = opstr.replace(/([^\\]|)A/g, "$1"+A); opstr = opstr.replace(/([^\\]|)H/g, "$1"+H); opstr = opstr.replace(/([^\\]|)h/g, "$1"+h); opstr = opstr.replace(/([^\\]|)G/g, "$1"+G); opstr = opstr.replace(/([^\\]|)g/g, "$1"+g); opstr = opstr.replace(/([^\\]|)i/g, "$1"+i); opstr = opstr.replace(/([^\\]|)s/g, "$1"+s); opstr = opstr.replace(/\\a/g, "a"); opstr = opstr.replace(/\\A/g, "A"); opstr = opstr.replace(/\\H/g, "H"); opstr = opstr.replace(/\\h/g, "h"); opstr = opstr.replace(/\\G/g, "G"); opstr = opstr.replace(/\\g/g, "g"); opstr = opstr.replace(/\\i/g, "i"); opstr = opstr.replace(/\\s/g, "s"); return opstr; } function set(e){ if(e=='')return; try{ var command = e.split(' '); var name = command[0]; command[0] = ''; var all = command.join(' '); GM_setValue(name,all); alert('Setting '+name + ' updated with ' + all); textbox.value = ''; }catch(e){ GM_log(e); } } function hookSubmit(){ unsafeWindow.checkName = function(){return start();} } function unhookSubmit(){ unsafeWindow.checkName = function(){return true;} } function start(){ var command = textbox.value; if(!command.match(/^\//)){ post(command); return false; } if(contShown){ hideCommandWind(); } /* dodgy plik =p this thing is mega annoying.. and should be an addeventlistener thing ... if(contShown){ if(suggestCmd) { textbox.value = "/" + suggestCmd + " "; return false; } } */ for(x in commands){ if(command == "/"+x){ commands[x](); return false; } else if(command == "//"+x){ post(command.substr(1)); return false; } var regexp = new RegExp('^\/'+x+' (.+|)$','i'); var regexptwo = new RegExp('^\/\/'+x+' (.+|)$','i'); var m = command.match(regexp); if(m){ commands[x](m[1]); return false; } else if(command.match(regexptwo)){ post(command.substr(1)); return false; } } post(command); return false; } function globalParser(text){ if(gC.length !=0){ for(var i=0;i.toString(); var styleElement = document.createElement("style"); styleElement.innerHTML = styles; var titlep = document.createElement("p"); titlep.setAttribute("id", "commandheader"); titlep.appendChild(document.createTextNode("Commands")); commandList.addEventListener("mousedown", commandClicked, true); cwContainer.appendChild(titlep); cwContainer.appendChild(commandList); var body = document.getElementsByTagName("body")[0]; body.appendChild(cwContainer); body.appendChild(styleElement); } function showCommandWind(){ cwContainer.style.display = "block"; suggestCommand(textbox.value) contShown = true; } function hideCommandWind(){ cwContainer.style.display = "none"; suggestCmd = false; var oldsug = document.getElementById("suggested"); if(oldsug) oldsug.removeAttribute("id"); contShown = false; } function commandClicked(e){ textbox.value = "/" + e.target.firstChild.data + " "; hideCommandWind(); textbox.focus(); } function closeWind(){ if(contShown){ if(textbox.value == "") return true; if(textbox.value.match(/^\/\//)) return true; if(textbox.value.match(/^\/\w+\s/)) return true; for(var i=0;i 9){ var offset = suggest - 9; cwContainer.scrollTop = offset * 28; } else { cwContainer.scrollTop = 0; } } function topLeftOffset(element) { var offsetX = element.offsetLeft; var offsetY = element.offsetTop; var parent = element.offsetParent while (parent) { var x = isNaN( parent.offsetLeft) ? 0 : parent.offsetLeft; var y = isNaN(parent.offsetTop) ? 0 : parent.offsetTop; offsetX = offsetX + x; offsetY = offsetY + y; parent = parent.offsetParent } return Array(offsetX,offsetY); } /* tab auto completer */ textbox.addEventListener("keypress",tabcompleter,false); var num = 0; var doubleTab = false; function tabcompleter(e){ var tab = 9; if(e.keyCode == tab){ //stop tab swapping elements... e.preventDefault(); if(!doubleTab){ oP = getOnlinePeople(); lW = getLastWord(textbox); } if(lW && oP){ if(!doubleTab){ pe = workOutPerson(lW.word,oP); if(pe.length==0)return false; }else{ if((num + 1) < pe.length){ num++; }else{ num=0; } } textbox.value = textbox.value.substring(0,lW.pos - lW.word.length) + pe[num] + textbox.value.substring(lW.pos,textbox.value.length); //enable doubleTab and set some values. lW.pos = lW.pos - lW.word.length + pe[num].length; lW.word = pe[num]; doubleTab = true; } }else{ num = 0; doubleTab = false; } } function workOutPerson(str,people){ var order = Array(); for(var i=0;i= 1){ var people = matches[1].split(','); for(var i=0;i 0){ return {'word' : splitme , 'pos' : start}; }else{ return false; } } } return false; } start_timer(); window.addEventListener("unload", end_timer, false); function start_timer(){ var date = new Date(); GM_setValue("session_start", String(date.getTime())); if(GM_getValue("session_total") == undefined){GM_setValue("session_total",0);} } function end_timer(){ GM_setValue("session_total", String(parseInt(GM_getValue("session_total")) + timer_getNow())); } function timer_getNow(){ var start = parseInt(GM_getValue("session_start")); var now = new Date(); var end = now.getTime(); return end - start; } function get_total_time_spent(){ var time = (timer_getNow() + parseInt(GM_getValue("session_total"))) / 1000; post("[b]Total time spent on the shoutbox[/b]: " + time_to_string(time)); } function time_to_string(time){ var secs = Math.round(time); var st = ''; var days = removeDec(secs / 86400); if(days >= 1){ if(days == 1){ st += days + ' day '; }else{ st += days + ' days '; } secs = secs - (days * 86400); } var hours = removeDec(secs / 3600); if(hours >= 1){ if(hours == 1){ st += hours + ' hour '; }else{ st += hours + ' hours '; } secs = secs - (hours * 3600) } var mins = removeDec(secs / 60); if(mins >= 1){ if(mins == 1){ st += mins + ' minute '; }else{ st += mins + ' minutes '; } secs = secs - (mins * 60); } st += 'and ' + secs + ' seconds' return st; } function removeDec(num){ return String(num).split('.')[0]; }