Jump to content

User:CanonNi/Scripts/StatusSetter.js

From Wikipedia, the free encyclopedia

This is the current revision of this page, as edited by CanonNi (talk | contribs) at 14:00, 12 July 2024 (minify). The present address (URL) is a permanent link to this version.

(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// 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]]