User:NJA/monobook.js

importScript('User:Animum/urlparameters.js'); importScript('User:Animum/formatresponse.js'); importScript('User:NuclearWarfare/Mark-blocked script.js'); importScript('User:Amalthea/userhighlighter.js'); importScript('User:Anomie/useridentifier.js'); // Linkback: User:Anomie/useridentifier.js

function textUpdate(text, br) { br = br || true; document.getElementById("contentSub").innerHTML += (br ? " " : "") + "" + text + ""; } function deleteRevision { if(!/[?&]diff=/.test(location.href) || !document.getElementById("mw-diff-ntitle1")) return; var confirmDelete = confirm("Only use this if it is in compliance with the actual Oversight policy.\n\nPlease do not use this as a substitute for Oversight, for vandalism or user requests, or if an RfO has already been filed."); if(!confirmDelete) return; var title_ = decodeURIComponent(document.getElementById("mw-diff-ntitle1").getElementsByTagName("a")[0].href.split("?title=")[1].split("&")[0]); var oldid = document.getElementById("mw-diff-ntitle1").getElementsByTagName("a")[0].href.split("oldid=")[1].split("&")[0]; var req = sajax_init_object; req.open("GET", mw.config.get('wgScriptPath') + "/api.php?format=json&action=query&prop=revisions&rvlimit=2&rvstartid=" + oldid + "&titles=" + encodeURIComponent(title_), false); req.send(null); var info = formatResponse(eval("(" + req.responseText + ")")); if(info.revisions) { var timestamp = info.revisions[0].timestamp.replace(/[^0-9]/g, ""); } else { return; }   delete req; var req = sajax_init_object; req.open("GET", mw.config.get('wgScriptPath') + "/api.php?format=json&action=query&prop=info&inprop=protection&titles=" + encodeURIComponent(title_), false); req.send(null); var info = formatResponse(eval("(" + req.responseText + ")")); var protlevels = {}; if(info.protection) { for(a=0;a<2;a++) { if(info.protection[a]) { var protection = info.protection[a]; protlevels[protection.type] = protection.level; protlevels[protection.type + "expiry"] = /[0-9]/.test(protection.expiry) ? protection.expiry.replace(/[^0-9]/g, "") : "never"; protlevels.cascade = protection.cascade ? true : false; }       }    }    textUpdate("Protection levels have been downloaded."); var req = sajax_init_object; req.open("GET", mw.config.get('wgScript') + "?title=Special:Undelete/" + encodeURIComponent(title_), false); req.send(null); var alreadyDeleted = new Array; var deletedrevs = req.responseText.split(" Page history ")[1].split(' ')[0]; if(deletedrevs.split("")[1]) { //If there are deleted revisions deletedrevs = deletedrevs.split("")[1].split("")[0].split(""); for(x=1; x")[0]) { if(deletedrevs[x].split("")[0].split('name="ts')[1].split('"')[0]) { alreadyDeleted.push(deletedrevs[x].split("")[0].split('<input name="ts')[1].split('"')[0]); }           }            if(x+1 == deletedrevs.length) break; }   }    textUpdate("List of already deleted revisions has been downloaded."); var reason = prompt("Optional reason (leave blank for default):"); var req = sajax_init_object; req.open("GET", mw.config.get('wgScriptPath') + "/api.php?format=json&action=query&prop=info&intoken=delete&titles=" + encodeURIComponent(title_), false); req.send(null); var deletetoken = formatResponse(eval("(" + req.responseText + ")")).deletetoken; var postdata = "format=json" + "&action=delete" + "&title=" + encodeURIComponent(title_) + "&reason=" + (reason.length > 0 ? encodeURIComponent(reason) : encodeURIComponent("Deleting to expunge a revision from this page's history")) + "&token=" + encodeURIComponent(deletetoken); var req = sajax_init_object; req.open("POST", mw.config.get('wgScriptPath') + "/api.php", false); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", postdata.length); req.send(postdata); if(eval("(" + req.responseText + ")").error) { textUpdate("Error: " + eval("(" + req.responseText + ")").error.info); return; }   textUpdate(title_ + " has been deleted."); delete req; var req = sajax_init_object; req.open("GET", mw.config.get('wgScript') + "?title=Special:Undelete/" + encodeURIComponent(title_), false); req.send(null); var revisionsToRestore = ""; var deletedrevs = req.responseText.split(" ")[1].split(' ')[0].split("")[1].split("")[0].split(""); for(x=1; x")[0]) { var ts = deletedrevs[x].split("")[0].split('name="ts')[1].split('"')[0]; //Timestamp of deleted revision if(ts != timestamp && alreadyDeleted.indexOf(ts) == -1) { revisionsToRestore += ts + (deletedrevs[x+1] ? "|" : ""); }       }        if(x+1 == deletedrevs.length) break; }   delete req; textUpdate("List of revisions to restore has been downloaded."); var req = sajax_init_object; req.open("GET", mw.config.get('wgScriptPath') + "/api.php?action=query&format=json&list=deletedrevs&titles=" + encodeURIComponent(title_) + "&drprop=token", false); req.send(null); var token = eval("(" + req.responseText + ")").query.deletedrevs[0].token; delete req; var postdata = "format=json" + "&action=undelete" + "&title=" + encodeURIComponent(title_) + "&reason=" + encodeURIComponent("Expunging revision from history") + "&token=" + encodeURIComponent(token) + "&timestamps=" + revisionsToRestore; var req = sajax_init_object; req.open("POST", mw.config.get('wgScriptPath') + "/api.php", false); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", postdata.length); req.send(postdata); if(eval("(" + req.responseText + ")").error) { textUpdate("Error: " + eval("(" + req.responseText + ")").error.info); return; }   textUpdate(title_ + " has been restored."); delete req; var req = sajax_init_object; req.open("GET", mw.config.get('wgScriptPath') + "/api.php?format=json&action=query&prop=info&intoken=protect&titles=" + encodeURIComponent(title_), false); req.send(null); var info = formatResponse(eval("(" + req.responseText + ")")); var token = info.protecttoken; delete req; if(protlevels.edit || protlevels.move) { var postdata = "format=json" + "&action=protect" + "&title=" + encodeURIComponent(title_) + "&protections=" + encodeURIComponent(protlevels.edit ? "edit=" + protlevels.edit + (protlevels.move ? "|move=" + protlevels.move : "") : (protlevels.move ? "move=" + protlevels.move : "")) + "&expiry=" + (protlevels.editexpiry ? protlevels.editexpiry + (protlevels.moveexpiry ? "|" + protlevels.moveexpiry : "") : (protlevels.moveexpiry ? protlevels.moveexpiry : "")) + "&token=" + encodeURIComponent(token) + (protlevels.cascade ? "&cascade=" : "") + "&reason=" + encodeURIComponent("Restoring original protection levels"); var req = sajax_init_object; req.open("POST", mw.config.get('wgScriptPath') + "/api.php", false); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", postdata.length); req.send(postdata); if(eval("(" + req.responseText + ")").error) { textUpdate("Error: " + eval("(" + req.responseText + ")").error.info); return; } else { textUpdate("Original protection levels have been restored."); }   }    textUpdate("Reloading page..."); location.href = mw.config.get('wgScript') + "?title=" + encodeURIComponent(mw.config.get('wgPageName')); //Reload/refresh } $(function {   if(/[?&]diff=/.test(location.href) && document.getElementById("mw-diff-ntitle1")) mw.util.addPortletLink("p-tb", "javascript:deleteRevision", "Delete revision", "ca-revdelete"); });

//this helps automate DRV closing by adding a 'close' tab to DRV debates when editing sections //written by User:Lifebaka, modified from WikiProject User scripts/Scripts/CloseAFD.js written by User:Johnleemk //to use this code, simply add importScript('User:Lifebaka/closedrv.js'); to your monobook.js page //feel free to copy and change this code as necessary (using your own copy, please); any modifications I have made from the source are public domain function autodrv_result { var close = prompt("Result of debate?") var f = document.editform, t = f.wpTextbox1; t.value = t.value.split('====').join('[['); t.value = t.value.split('====').join(']]|2=' + close + '|undefined'); if (t.value.length > 0) t.value += '\n'; t.value += ""; f.wpSummary.value += "closing: " + close; } function autodrv_add_drv_tabs { // Only add for pages with the right string somewhere in the title if ((document.title.indexOf("Editing Wikipedia:Deletion review/Log/") != -1) && (document.title.indexOf("(section)") != -1)) {     mw.util.addPortletLink('p-cactions', 'javascript:autodrv_result', "close"); } } $(autodrv_add_drv_tabs);

importScript("User:Animum/easyblock.js"); //User:Animum/easyblock.jsmum/easyblock.js]] importScript('Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited'); importScript('User:MarkS/extraeditbuttons.js'); //User:MarkS/extraeditbuttons.js

// User:Jsimlo/shortcuts.js document.write(' '); function shortcutsInit {

shortcutsAddLink ('Abuse log', 'Special:AbuseLog'); shortcutsAddLink ('Admin Dashboard', 'Template:Admin_dashboard'); shortcutsAddLink ('Admin Noticeboard', 'Wikipedia:Administrators%27_noticeboard'); shortcutsAddLink ('My logs', 'User:NJA/Admin'); }

// CloseAFD script + hide closed - Script to easily close AFDs, including doing all edits needed to logs and the articles / Script that allows hiding all closed AFDs on a log page importScript('User:Mr.Z-man/closeAFD.js'); importScript('User:Mr.Z-man/hideClosedAFD.js');

// Allows to easily cast !votes on AFDs importScript('User:Jnothman/afd_helper/script.js');

function menu_move_to_top(menu_name) { menu = document.getElementById(menu_name); if (menu) { p = menu.parentNode; p.removeChild(menu); p.insertBefore( menu, p.firstChild ); } }

$(function {    var rights_isAdmin = (mw.config.get('wgUserGroups').toString.indexOf('sysop') != -1);    if (!rights_isAdmin)        return; //Restrict to admins.    if (mw.config.get('wgNamespaceNumber') != "2" && mw.config.get('wgNamespaceNumber') != "3")        return;  // restrict to User and User talk    var title = mw.config.get('wgTitle');    mw.util.addPortletLink('p-tb', '/wiki/Special:Userrights/'+title, 'User rights', 't-userrights', 'User rights for "'+title+'"'); });

//User:ais523 non-admin/adminrights.js // // This script highlights bluelinks to admins' userpages or talkpages in bodyContent (that is, everything but the tabs, personal // links at the top of the screen and sidebar) by giving them a cyan background. Please import this script using importScript, // rather than copying the code, as the list of admins is hard-coded for performance and if you copy the code the list won't update // with time (I update it from time to time). You can do this by substing Template:js with this script's name as an argument in your // monobook.js. // // If you want a colour other than cyan, add // .ais523_adminrights_admin {background-color: #FFFF00 !important} // (or any other colour code) to your monobook.css file. //Update this list at //http://en.wikipedia.org/w/index.php?title=Special:Listusers&limit=5000&group=sysop&ais523update=y var adminrights=new Array; importScript('User:Ais523/adminrights-admins.js'); //User:Ais523/adminrights.js //Updating script $(function{ if(location.href=="http://en.wikipedia.org/w/index.php?title=Special:ListUsers&limit=5000&"+ "group=sysop&ais523update=y") {    var h=document.getElementById('bodyContent').innerHTML;    var a=new Array;    h=h.split(/\< *li *\>/i);    var i=0;    while(++i")[1].split("<")[0]]=h[i].split(/\< *\/ *li *\>/i)[0];    }    for(i in a)    {      document.write("adminrights['"+ encodeURIComponent(i).split("\\").join("\\\\").split("'").join("%27") .split("(").join("%28").split(")").join("%29") .split("%21").join("!").split("%2C").join(",") .split("%3A").join(":")+"']=1;");   }  } }); //Highlighting script. Based on User:ais523/highlightmyname.js. function highlightadmins(n,p) //node, parent node { while(n!=null) {   if(n.nodeType==1&&n.tagName.toLowerCase=="a") //anchor {     if(n.href.indexOf("http://en.wikipedia.org/wiki/User:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/User:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+="ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/wiki/User_talk:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/User_talk:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/wiki/Special:Contributions:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/Special:Contributions:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/w/index.php?title=User:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/w/index.php?title=User:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/w/index.php?title=User_talk:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/w/index.php?title=User_talk:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#00FFFF"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else {       if(n.firstChild!=null) highlightadmins(n.firstChild,n); n=n.nextSibling; }   }    else {     if(n.firstChild!=null) highlightadmins(n.firstChild,n); n=n.nextSibling; } } } $(function {  if(location.href.indexOf("?ais523")==-1&&location.href.indexOf("&ais523")==-1&& location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&& location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&& mw.config.get('wgPageName')!="Special:Preferences") {    highlightadmins(document.getElementById('bodyContent').firstChild, document.getElementById('bodyContent')); } }); //Highlighting script. Based on User:ais523/highlightmyname.js. function highlightadmins(n,p) //node, parent node { while(n!=null) {   if(n.nodeType==1&&n.tagName.toLowerCase=="a") //anchor {     if(n.href.indexOf("http://en.wikipedia.org/wiki/User:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/User:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#fff8ad"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+="ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/wiki/User_talk:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/User_talk:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#fff8ad"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/wiki/Special:Contributions:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/wiki/Special:Contributions:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#fff8ad"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/w/index.php?title=User:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/w/index.php?title=User:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#fff8ad"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else if(n.href.indexOf("http://en.wikipedia.org/w/index.php?title=User_talk:")!=-1) {       var u=n.href.split("http://en.wikipedia.org/w/index.php?title=User_talk:")[1]; if(adminrights[u.split("_").join("%20")]==1) {         n.style.backgroundColor="#fff8ad"; if(n.className==null||n.className=="") n.className="ais523_adminrights_admin"; else n.className+=" ais523_adminrights_admin"; }       n=n.nextSibling; }     else {       if(n.firstChild!=null) highlightadmins(n.firstChild,n); n=n.nextSibling; }   }    else {     if(n.firstChild!=null) highlightadmins(n.firstChild,n); n=n.nextSibling; } } } $(function {  if(location.href.indexOf("?ais523")==-1&&location.href.indexOf("&ais523")==-1&& location.href.indexOf("?action=edit")==-1&&location.href.indexOf("?action=submit")==-1&& location.href.indexOf("&action=edit")==-1&&location.href.indexOf("&action=submit")==-1&& mw.config.get('wgPageName')!="Special:Preferences") {    highlightadmins(document.getElementById('bodyContent').firstChild, document.getElementById('bodyContent')); } });

//Mass rollback function //Written by John254 //Adapted from User:Mr.Z-man/rollbackSummary.js //Instructions: Selecting the "rollback all" tab when viewing a user's contributions history //will open all rollback links displayed there. (Use with caution) function rollbackEverythingButton { var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link"); if (hasRollback[0] && (document.title.indexOf("User contributions") != -1) ) { mw.util.addPortletLink('p-cactions', 'javascript:rollbackEverything', "rollback all", "ca-rollbackeverything", "rollback all edits displayed here"); } } $(rollbackEverythingButton); function rollbackEverything { for (var i in document.links) { if (document.links[i].href.indexOf('action=rollback') != -1) { window.open(document.links[i].href); }   } } // based on http://en.wikipedia.org/wiki/User:Fran Rogers/dimorphism.js // and on http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js function UserinfoJsFormatQty(qty, singular, plural) { return String(qty).replace(/\d{1,3}(?=(\d{3})+(?!\d))/g, "$&,") + "\u00a0" + (qty == 1 ? singular : plural); } function UserinfoJsFormatDateRel(old) { // The code below requires the computer's clock to be set correctly. var age = new Date.getTime - old.getTime; var ageNumber, ageRemainder, ageWords; if(age < 60000) { // less than one minute old ageNumber = Math.floor(age / 1000); ageWords = UserinfoJsFormatQty(ageNumber, "second", "seconds"); } else if(age < 3600000) { // less than one hour old ageNumber = Math.floor(age / 60000); ageWords = UserinfoJsFormatQty(ageNumber, "minute", "minutes"); } else if(age < 86400000) { // less than one day old ageNumber = Math.floor(age / 3600000); ageWords = UserinfoJsFormatQty(ageNumber, "hour", "hours"); ageRemainder = Math.floor((age - ageNumber * 3600000) / 60000); } else if(age < 604800000) { // less than one week old ageNumber = Math.floor(age / 86400000); ageWords = UserinfoJsFormatQty(ageNumber, "day", "days"); } else if(age < 2592000000) { // less than one month old ageNumber = Math.floor(age / 604800000); ageWords = UserinfoJsFormatQty(ageNumber, "week", "weeks"); } else if(age < 31536000000) { // less than one year old ageNumber = Math.floor(age / 2592000000); ageWords = UserinfoJsFormatQty(ageNumber, "month", "months"); } else { // one year or older ageNumber = Math.floor(age / 31536000000); ageWords = UserinfoJsFormatQty(ageNumber, "year", "years"); ageRemainder = Math.floor((age - ageNumber * 31536000000) / 2592000000); if(ageRemainder) { ageWords += " " + UserinfoJsFormatQty(ageRemainder, "month", "months"); }          }           return ageWords; } // If on a user or user talk page, and not a subpage... if((mw.config.get("wgNamespaceNumber") == 2 || mw.config.get("wgNamespaceNumber") == 3) && !(/\//.test(mw.config.get("wgTitle")))) { // add a hook to... mw.loader.using( ['es5-shim', 'mediawiki.util'], function { $(function{ // Request the user's information from the API. // Note that this is allowed to be up to 5 minutes old. var et = encodeURIComponent(mw.config.get("wgTitle")); $.getJSON(mw.config.get("wgScriptPath") + "/api.php?format=json&action=query&list=users|usercontribs&usprop=blockinfo|editcount|gender|registration|groups&uclimit=1&ucprop=timestamp&ususers=" + et + "&ucuser=" + et + "&meta=allmessages&amfilter=grouppage") .done(function(query) {           // When response arrives extract the information we need.            if(!query.query) { return; } // Suggested by Gary King to avoid JS errors --PS 2010-08-25            query = query.query;            var user, invalid, missing, groups, groupPages={}, editcount, registration, blocked, gender, lastEdited;            try {                user = query.users[0];                invalid = typeof user.invalid != "undefined";                missing = typeof user.missing != "undefined";                groups = (typeof user.groups == "object") ? user.groups : [];                editcount = (typeof user.editcount == "number") ? user.editcount : null;                registration = (typeof user.registration == "string") ?                    new Date(user.registration) : null;                blocked = typeof user.blockedby != "undefined";                gender = (typeof user.gender == "string") ? user.gender : null; lastEdited = (typeof query.usercontribs[0] == "object") && (typeof query.usercontribs[0].timestamp == "string") ? new Date(query.usercontribs[0].timestamp) : null; for (var am=0; am<query.allmessages.length; am++) { groupPages[query.allmessages[am]["name"].replace("grouppage-","")] = query.allmessages[am]["*"].replace("   :","Project:"); }           } catch(e) { return; // Not much to do if the server is returning an error (e.g. if the username is malformed). }           // Format the information for on-screen display var statusText = ""; var ipUser = false; var ipv4User = false; var ipv6User = false; // User status if(blocked) { statusText += "blocked</a> "; }           if (missing) { statusText += "username not registered"; } else if (invalid) { ipv4User = mw.util.isIPv4Address(user.name); ipv6User = mw.util.isIPv6Address(user.name); ipUser = ipv4User || ipv6User; if (ipv4User) { statusText += "anonymous IPv4 user"; } else if (ipv6User) { statusText += "anonymous IPv6 user"; } else { statusText += "invalid username"; }           } else { // User is registered and may be in a privileged group. Below we have a list of user groups. // Only need the ones different from the software's name (or ones to exclude), though. var friendlyGroupNames = { // Exclude implicit user group information provided by MW 1.17 --PS 2010-02-17 '*': false, 'user': false, 'autoconfirmed': false, sysop: "administrator", accountcreator: "account creator", 'import': "importer", transwiki: "transwiki importer", 'ipblock-exempt': "IP block exemption", oversight: "oversighter", confirmed: "confirmed user", abusefilter: "edit filter manager", autoreviewer: "autopatrolled user", // Group has been renamed --PS 2010-07-06 epcoordinator: "Education Program course coordinator", epcampus: "Education Program campus volunteer", eponline: "Education Program online volunteer", filemover: "file mover", 'massmessage-sender': "mass message sender", templateeditor: "template editor" };               var friendlyGroups = []; for(var i = 0; i < groups.length; ++i) { var s = groups[i]; if(friendlyGroupNames.hasOwnProperty(s)) { if(friendlyGroupNames[s]) { friendlyGroups.push("<a href='/wiki/" + encodeURIComponent( groupPages[s] ) + "'>" + friendlyGroupNames[s] + "</a>"); }                   } else { friendlyGroups.push("<a href='/wiki/" + encodeURIComponent( groupPages[s] ) + "'>" + s + "</a>"); }               }                switch(friendlyGroups.length) { case 0: // User not in a privileged group // Changed to "registered user" by request of User:Svanslyck // --PS 2010-05-16 // statusText += "user"; if(blocked) { statusText += "user"; } else { statusText += "registered user"; }                       break; case 1: statusText += friendlyGroups[0]; break; case 2: statusText += friendlyGroups[0] + " and " + friendlyGroups[1]; break; default: statusText += friendlyGroups.slice(0, -1).join(", ") + ", and " + friendlyGroups[friendlyGroups.length - 1]; break; }           }            // Registration date if(registration) { var firstLoggedUser = new Date("22:16, 7 September 2005"); // When the Special:Log/newusers was first activated if(registration >= firstLoggedUser) { statusText += ", <a href='" + mw.config.get("wgScriptPath") + "/index.php?title=Special:Log&type=newusers&dir=prev&limit=1&user=" + et + "'>" + UserinfoJsFormatDateRel(registration) + "</a> old"; } else { statusText += ", <a href='" + mw.config.get("wgScriptPath") + "/index.php?title=Special:ListUsers&limit=1&username=" + et + "'>" + UserinfoJsFormatDateRel(registration) + "</a> old"; }           }            // Edit count if(editcount !== null) { statusText += ", with " + "<a href=\"//tools.wmflabs.org/xtools-ec/?user=" +                   encodeURIComponent(user.name) +                    "&project=en.wikipedia.org&uselang=en\">" + UserinfoJsFormatQty(editcount, "edit", "edits") + "</a>"; }           // Prefix status text with correct article if("AEIOaeio".indexOf(statusText.charAt(statusText.indexOf('>')+1)) >= 0) { statusText = "An " + statusText; } else { statusText = "A " + statusText; }           // Add full stop to status text statusText += "."; // Last edited --PS 2010-06-27 // Added link to contributions page --PS 2010-07-03 if(lastEdited) { statusText += " Last edited <a href=\"" + mw.config.get("wgArticlePath").replace("$1", "Special:Contributions/" + encodeURIComponent(user.name)) + "\">" + UserinfoJsFormatDateRel(lastEdited) + " ago</a>."; }           // Show the correct gender symbol var fh = document.getElementById("firstHeading") || document.getElementById("section-0"); // Add classes for blocked, registered, and anonymous users var newClasses = []; if(blocked) { newClasses.push("ps-blocked"); }           if(ipUser) { newClasses.push("ps-anonymous"); } else if(invalid) { newClasses.push("ps-invalid"); } else { newClasses.push("ps-registered"); }           fh.className += (fh.className.length ? " " : "") + groups.map(function(s) {                return "ps-group-" + s;            }).concat(newClasses).join(" "); var genderSpan = document.createElement("span"); genderSpan.id = "ps-gender-" + (gender || "unknown"); genderSpan.style.paddingLeft = "0.25em"; genderSpan.style.fontFamily = '"Lucida Grande", "Lucida Sans Unicode", "sans-serif"'; genderSpan.style.fontSize = "75%"; var genderSymbol; switch(gender) { case "male": genderSymbol = "\u2642"; break; case "female": genderSymbol = "\u2640"; break; default: genderSymbol = ""; break; }           genderSpan.appendChild(document.createTextNode(genderSymbol)); fh.appendChild(genderSpan); // Now show the other information. Non-standard? Yes, but it gets the job done. // Add a period after the tagline when doing so. --PS 2010-07-03 var ss = document.getElementById("siteSub"); if(!ss) { ss = document.createElement("div"); ss.id = "siteSub"; ss.innerHTML = "From Wikipedia, the free encyclopedia"; var bc = document.getElementById("bodyContent"); bc.insertBefore(ss, bc.firstChild); }           ss.innerHTML = ' ' + statusText + ' ' + ss.innerHTML + '.'; ss.style.display = "block"; });   }); }); } /* This script adds Contributions and Statistics tabs to User and User talk pages. For Vector skin. To use this script, place the following line in your vector.js page:    importScript('User:Equazcion/ContribsTabVector.js'); Add any or all of these lines after the importScript line above to set various options (the default values are shown):    var contribsTab = true;                    // Turns the Contributions tab on or off (set to false; for off)    var contribsTabStats = true;               // Turns the Statistics tab on or off (set to false; for off)    var contribsTabNumber = 50;                // Number of contributions to display in the Contributions tab. Can be 1 to 5000.    var contribsTabName = "Contributions";     // Custom name for Contributions tab. Replace quoted text with your desired name.    var contribsTabStatsName = "Statistics";   // Custom name for Statistics tab. Replace quoted text with your desired name. -- End of documentation -- */ if (mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3) { // Don't do anything unless we're in user or usertalk space // Set default options for any that haven't been set if (contribsTabName == null) var contribsTabName = "Contributions"; if (contribsTabNumber == null) var contribsTabNumber = 50; if (contribsTabStats == null) var contribsTabStats = true; if (contribsTab == null) var contribsTab = true; if (contribsTabStatsName == null) var contribsTabStatsName = "Statistics"; // Get the current page's username var username = mw.config.get('wgTitle').split("/")[0]; // Grab leftmost tab var contribsTabMain = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9'); if (contribsTab) { // Construct the contribs tab, if it's not turned off // Clone main page tab, remove 'new' class in case it was red var tabContribs = contribsTabMain.clone(true).attr('id', contribsTabMain.attr('id')+'-').css('opacity','0.9').removeClass('new'); // Construct contribs URL if (mw.config.get('wgNoticeProject') == 'commons') { var contribsTabURL = 'http://commons.wikimedia.org/w/index.php?title=Special:Contributions&target=' + username + '&limit=' + contribsTabNumber + '&uselang=' + mw.config.get('wgPageContentLanguage'); } else { var contribsTabURL = 'http://' + mw.config.get('wgPageContentLanguage') + '.' + mw.config.get('wgNoticeProject') + '.org/w/index.php?title=Special:Contributions&target=' + username + '&limit=' + contribsTabNumber + '&uselang=' + mw.config.get('wgPageContentLanguage'); }    // Set contribs tab URL, text, and tooltip tabContribs.find('a').attr('href', contribsTabURL).empty.text(contribsTabName).attr('title', "Show this user's contributions"); } if (contribsTabStats) { // Construct the stats tab, if it's not turned off // Clone main page tab, remove 'new' class in case it was red var tabStats = contribsTabMain.clone(true).attr('id', contribsTabMain.attr('id')+'-').css('opacity','0.9').removeClass('new'); // Construct stats URL var contribsTabStatsURL = 'https://tools.wmflabs.org/supercount/index.php?user= ' + username + '&project=' + mw.config.get('wgPageContentLanguage') + '.' + mw.config.get('wgNoticeProject'); // Set stats tab URL, text, and tooltip tabStats.find('a').attr('href', contribsTabStatsURL).empty.text(contribsTabStatsName).attr('title', "Show this user's editing statistics"); } // Place constructed tabs before the first right-hand tab (done here for easy ordering) if (contribsTabStats) tabStats.insertBefore($('#right-navigation li').slice(0,1)); if (contribsTab) tabContribs.insertBefore($('#right-navigation li').slice(0,1)); } /* Modified version of User:Splarka/sysopdectector.js Sysop decrier/detector (rights group displayer), version [0.2.0a] Originally from http://en.wikipedia.org/wiki/User:Splarka/sysopdectector.js Options: var showUserGroupSettings = { 'IP':true, 'unregistered':true, 'registered':true, 'groups': true, 'editcount':true, 'regdate':true, 'blocked':true }; if ((mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3) && (mw.config.get('wgTitle').indexOf('/') == -1) && (mw.config.get('wgAction') == 'view')) { addOnloadHook(showUserGroups); } function showUserGroups { var url = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/api.php?action=query&format=json&callback=showUserGroupsCB&maxage=3600&smaxage=3600&usprop=blockinfo|groups|editcount|registration&list=users&ususers=' + encodeURIComponent(mw.config.get('wgTitle')); mw.loader.load(url); } function showUserGroupsCB(obj) { var show = window.showUserGroupSettings || false; if ( obj['query'] && obj['query']['users'] ) { var user = obj['query']['users']; } else { return; } if ( user.length > 0 ) { user = user[0]; } else { return; } if ( $('h1, h2').length > 0) { var someHeading = $('h1:first') || $('h2:first'); } else { return; } var title = 'User:' + user['name'] + ' '; someHeading.attr('title', title).addClass('detected-userrights-heading'); var text = ' '; if (user['invalid'] == '') { if (show && show.IP) text += '[IP] '; else title += '[invalid or IP username] '; } else if (user['missing'] == '') { if (show && show.unregistered) text += '[doesn\'t exist] '; else title += '[not a registered name] '; } else { if (show && show.registered) text += '[exists] '; else title += '[username registered] '; if (user['groups']) { user['groups'].splice( user['groups'].indexOf('user'), 1); user['groups'].splice( user['groups'].indexOf('*'), 1); if ((show && show.groups || !show) && (user['groups'].length > 1)) { text += ('[' + user['groups'] + '] ').replace(/,/gi, ", "); } else { title += '[' + user['groups'] + '] '; }		}		if ( user['editcount'] ) { if (show && show.editcount) text += '[' + user['editcount'] + ' edits] '; else title += '[' + user['editcount'] + ' edits] '; }		if ( user['registration'] ) { if (show && show.regdate) text += '[created: ' + user['registration'].split('T')[0] + '] '; else title += '[created: ' + user['registration'] + '] '; }		if ( user['blockedby'] ) { if (show && show.blocked) text += '[blocked] '; else text += '[currently blocked] '; }	}	var span = $(' ', {		'text': text, 		'style':'font-size:80%;', 		'class':'detected-userrights'	}).appendTo(someHeading); }
 * All are assumed false if omitted. All but 'groups' are assumed false if undefined.