User:CanonNi/Scripts/StatusSetter.js
Appearance
< User:CanonNi | Scripts
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:CanonNi/Scripts/StatusSetter. |
// Fork of [[User:Enterprisey/StatusChanger.js]]
// Minified code, see [https://github.com/canonnizq/wikipedia-scripts/blob/main/scripts/StatusSetter.js] for a human-readable version
// <nowiki>
$.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 [[User:CanonNi/Scripts/StatusSetter|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))}}});
// </nowiki>
// [[Category:Wikipedia scripts]]