Jump to content

User:Cuckooman4/statustabs.js

From Wikipedia, the free encyclopedia
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.
//Made by cuckooman4.
//
//See /doc
//<pre><nowiki>

if(!statuspageurl) var statuspageurl = "Status"
if(!statustemplateurl) var statustemplateurl = "StatusTemplate"
if(!statussyntax) var statussyntax = "{{User:" + wgUserName + "/" + statustemplateurl + "|%STATUSPARAMS%}}"
if(!statustabs) var statustabs = ["on","off"]

addOnloadHook(
  function() {
    var i = 0
    while(i < statustabs.length) {
      mw.util.addPortletLink('p-cactions', mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=User:" + wgUserName + "/" + statuspageurl + "&action=edit&autostatus=" + encodeURIComponent(statustabs[i]), statustabs[i], 'ca-status' + i)
      i++
    }

    if(location.href.indexOf("&autostatus=") != -1) {
      var statusurlvar = location.href.split("&autostatus=")[1]
      document.getElementById("wpTextbox1").innerText = statussyntax.split("%STATUSPARAMS%")[0] + statusurlvar + statussyntax.split("%STATUSPARAMS%")[1]
      document.getElementById("wpSummary").value = "Changing status: " + statusurlvar
      document.getElementById("wpMinoredit").checked = false
      document.getElementById("editform").submit()
    }
  }
)

//</nowiki></pre>