User:Flameviper/Status changer

This is my script for a status changer, written by Topaz. Allows you to set a status (online, offline, or busy). You can fool around with the displayed content for either (for example, I switched "Busy" to "on wikivacation"). However, for some reason, you can't change the tab names themselves. Don't try. Also, be sure to replace every instance of "flameviper" with your username. Don't replace instances of "topaz".

Related links

 * User:Topaz/Wikiscripts
 * User:Flameviper/scripts
 * Monobook

To put this in your monobook, click on "view source" and copy everything below this line:

var flameviper = new Object; flameviper.util = { getobj:function(id) { return document.getElementById ? document.getElementById(id) : document.all[id]; }, add:function(parent, tag, attr) { var el = document.createElement(tag); if (attr) { for (key in attr) { el[key] = attr[key]; } }  return parent.appendChild(el); }, mousebtnmap:{ ns:[null,1,3,2], ie:[null,1,2,null,3] }, xmlhttpreq:function { if (window.XMLHttpRequest) { xmlhttpobj = new XMLHttpRequest } else { try { xmlhttpobj = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttpobj = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { xmlhttpobj = null; }   }  }  return xmlhttpobj; } }; flameviper.comm = { doreq:function(url,postdata,headers) { var req = flameviper.util.xmlhttpreq; req.open(postdata?"POST":"GET", url, false); for(header in headers) { req.setRequestHeader(header,headers[header]); } req.send(postdata||null); return req; } }; flameviper.wputil = { username:function { return wgUserName; //return flameviper.util.getobj("pt-userpage").childNodes[0].childNodes[0].nodeValue; }, iseditpage:function { return document.title.indexOf("Editing ")==0; }, pagename:function { var iseditpage = flameviper.wputil.iseditpage; return document.title.substr(iseditpage?8:0,document.title.indexOf(" - ")-(iseditpage?8:0)); }, addsidepanel:function(id,label) { var div = flameviper.util.add(flameviper.util.getobj("column-one"), "div", {className:"portlet",id:id}); flameviper.util.add(div, "H5").innerHTML = label; flameviper.util.add(flameviper.util.add(div, "div", {className:"pBody"}), "ul"); }, addsidepanelbutton:function(id,label,targhref) { var li = flameviper.util.add((flameviper.util.getobj(id).getElementsByTagName("ul"))[0],"li"); with(flameviper.util.add(li,"a")) { innerHTML = label; href = targhref; } return li; }, setpagecontent:function(pagename,content,summary,watch) { var prelimresp = flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=submit"); var edittime = prelimresp.responseText.match(/\/)[1]; var edittoken = prelimresp.responseText.match(/\/)[1]; flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=submit",     "wpEdittime="+edittime+      "&wpEditToken="+edittoken+      "&wpTextbox1="+escape(content)+      "&wpSummary="+escape(summary)+      (watch?"&wpWatchthis=on":"")+      "&wpSection=&wpSave=Save+page",      {"Content-Type":"application/x-www-form-urlencoded"}); }, getpagecontent:function (pagename) { var req = flameviper.comm.doreq("/w/index.php?title="+pagename+"&action=edit"); var content = req.responseText.match(/\([\w\W]*?)\<\/textarea\>/)[1]; content = content.replace(/\&lt\;/gi, "<"); content = content.replace(/\&gt\;/gi, ">"); content = content.replace(/\&quot\;/gi, "\""); content = content.replace(/\&amp\;/gi, "&");  return content; } }; flameviper.statuschanger = new Object;

/* configuration */ // change these to whatever you'd like to show up on your status page. flameviper.statuschanger.statuscode = { online:' online ', busy:' on wikivacation ', offline:' offline ' }; // true to use the personal bar, false to create a panel in the left column flameviper.statuschanger.usepersonalbar = false; // true if you'd like your status page on your watchlist flameviper.statuschanger.watchstatus = false; /* end configuration */

flameviper.statuschanger.oldonload = window.onload; window.onload = function { if (typeof flameviper.statuschanger.oldonload == "function"){setTimeout('flameviper.statuschanger.oldonload',50);} if (flameviper.statuschanger.usepersonalbar) { var a = flameviper.wputil.addsidepanelbutton("p-personal", "Online",       'javascript:flameviper.statuschanger.setstatus("online")'    ); var b = flameviper.wputil.addsidepanelbutton("p-personal", "Offline",       'javascript:flameviper.statuschanger.setstatus("offline")'    ); var c = flameviper.wputil.addsidepanelbutton("p-personal", "Vacation",       'javascript:flameviper.statuschanger.setstatus("busy")'    ); a.style.borderRight=b.style.borderRight="1px solid #aaaaaa"; b.style.marginLeft=c.style.marginLeft="0px"; a.style.paddingRight=b.style.paddingLeft=b.style.paddingRight=c.style.paddingLeft="2px"; } else { flameviper.wputil.addsidepanel("tz-statuschanger", "status changer"); flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Online",       'javascript:flameviper.statuschanger.setstatus("online")'    ); flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Busy",       'javascript:flameviper.statuschanger.setstatus("busy")'    ); flameviper.wputil.addsidepanelbutton("tz-statuschanger", "Offline",       'javascript:flameviper.statuschanger.setstatus("offline")'    ); } };

flameviper.statuschanger.setstatus = function(statusname) { flameviper.wputil.setpagecontent(     "User:"+flameviper.wputil.username+"/Status",      flameviper.statuschanger.statuscode[statusname],      statusname,      flameviper.statuschanger.watchstatus); };