User:CanonNi/Scripts/StatusSetter.js

// Fork of User:Enterprisey/StatusChanger.js // Minified code, see for a human-readable version //

$.when($.ready,mw.loader.using("mediawiki.api")).then(function{if(typeof statusSetterConfig=="undefined"){statusSetterConfig={}}if(typeof statusSetterConfig.statusList=="undefined"){statusSetterConfig.statusList=["somewhere","in","editing","online","offline","busy","sleeping","wikibreak","away","vandal","holiday","school","working","eating","huggle","twinkle"]}if(typeof statusSetterConfig.statusPage=="undefined"){statusSetterConfig.statusPage="User:"+mw.config.get("wgUserName")+"/Status"}function makeListener(newStatus){return function(evt){evt.preventDefault;var api=new mw.Api({ajax:{headers:{"Api-User-Agent":"User:CanonNi/Scripts/StatusSetter.js"}}});api.postWithEditToken({action:"edit",title:statusSetterConfig.statusPage,text:newStatus,summary:"Set status to "+newStatus+" using StatusSetter"}).then(function{api.post({action:"purge",titles:"User:"+mw.config.get("wgUserName")});mw.notify("Done setting status!")});return false}}if(mw.config.get("wgTitle")===mw.config.get("wgUserName")|mw.config.get("wgPageName")==="User:CanonNi/Scripts/StatusSetter"){mw.util.addPortlet("p-status","Status","#p-cactions");for(var i=0;i<statusSetterConfig.statusList.length;i++){var stat=statusSetterConfig.statusList[i];mw.util.addPortletLink("p-status","#",stat.charAt(0).toUpperCase+stat.slice(1),"pt-status-"+stat,"Set status to "+stat).addEventListener("click",makeListener(stat))}}});

// //