Jump to content

User:EurovisionNim/common.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.
mw.loader.load( "https://meta.wikimedia.org/w/index.php?title=User:Zhaofeng_Li/Reflinks.js&action=raw&ctype=text/javascript" );
// 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("{{ns:project}}:","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 += "<a href=\"" + mw.config.get("wgScriptPath") +
                    "/index.php?title=Special:Log&amp;page=" + 
                    encodeURIComponent(mw.config.get("wgFormattedNamespaces")[2] + ":" + user.name) +
                    "&amp;type=block\">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&amp;type=newusers&amp;dir=prev&amp;limit=1&amp;user=" +
                    et + "'>" + UserinfoJsFormatDateRel(registration) + "</a> old";
            	} else {
            		statusText += ", <a href='" + mw.config.get("wgScriptPath") +
                    "/index.php?title=Special:ListUsers&amp;limit=1&amp;username=" +
                    et + "'>" + UserinfoJsFormatDateRel(registration) + "</a> old";
            	}
            }
            
            // Edit count
            if(editcount !== null) {
                statusText += ", with " +
                    "<a href=\"//tools.wmflabs.org/xtools-ec/?user=" +
                    encodeURIComponent(user.name) +
                    "&amp;project=en.wikipedia.org&amp;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 = '<span id="ps-userinfo">' + statusText + '</span> ' + ss.innerHTML + '.';
            ss.style.display = "block";
            });
    }); });
}

/*
 
 Put some functions in the toolbox for the anti-vandal whack-a-mole game.
 Documented at http://en.wikipedia.org/wiki/User:Kbh3rd/Vandal_warning_toolbox
 
 */
 // <pre><nowiki>
 
 
 // ****************
 //  Google Lookup 
 // ****************
 function whackGoogleLookup () {
    var q = "" + (window.getSelection ? window.getSelection()
                                      : document.getSelection ? document.getSelection()
                                                              : document.selection.createRange().text);
    if (!q)
        q = prompt("You didn't select any text.  Enter a search phrase:", "");
    if (q!=null)
        // location="http://www.google.com/search?q=" + escape(q).replace(/ /g, "+");
        window.open("http://www.google.com/search?q=" + escape(q).replace(/ /g, "+") ,'new-tab') ;
 }
 
 // **************
 // Month section
 // **************
 
 function whackMonth () {
    var d=new Date()
    var f = document.editform ;
 
    var month=new Array(12)
    month[0]="January"; month[1]="February"; month[2]="March"; month[3]="April"; month[4]="May"; month[5]="June";
    month[6]="July"; month[7]="August"; month[8]="September"; month[9]="October";
    month[10]="November"; month[11]="December";
 
    f.wpTextbox1.value += "\n== "+month[d.getMonth()]+" "+d.getFullYear()+" ==\n\n" ;
    f.wpSummary.value = month[d.getMonth()] ;
    f.wpMinoredit.checked=true;
    f.wpWatchthis.checked=false;
    if (f.wpTextbox1.scrollTop || true)
      f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ;
 }
 
 // **
 // Check for month when making an edit
 // **
 
 function whackCheckMonth () {
 
    var d=new Date()
    var f = document.editform ;
 
    var month=new Array( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December") ;
    var myregexstr = new String ('== *' + month[d.getMonth()] + " " + d.getFullYear() + ' *==') ;
    var myregex = new RegExp(myregexstr);
    if (myregex.test(f.wpTextbox1.value) != true) {
        f.wpTextbox1.value += "\n== "+month[d.getMonth()]+" "+d.getFullYear()+" ==\n" ;
        f.wpSummary.value = month[d.getMonth()] ;
        if (f.wpTextbox1.scrollTop || true)
          f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ;
    }
 }
 
 
 
 // **************
 // Warnings
 // **************
 
 function whackEdit (message, msg2, summary, level) {
    var f = document.editform ;
    var tbox = document.editform.wpTextbox1 ;
    var a = "" + (window.getSelection ? window.getSelection()
                                      : document.getSelection ? document.getSelection()
                                                              : document.selection.createRange().text);
    if (msg2 != "") {
      a = prompt ("Article name?\n(Empty+OK for a generic message; Cancel aborts.)", a) ;
      if (a == null) return ;
      a = a.replace(/^\s+/, '') ;
      a = a.replace(/\.?\s*$/, '');
 
      if (a != null && a != "") {
        message = message.replace(/\|/,"|"+a) ;
        summary += " in [[" + a + "]]" ;
      } else {
        message = msg2 ;
      }
    }
    whackCheckMonth () ;
    f.wpTextbox1.value += "\n\n" + message + " <br clear=\"both\" />\n" ;
    f.wpSummary.value = summary ;
    if (level > 0) { f.wpSummary.value += " /"+level+"/" ; }
    if (document.getElementById('wpMinoredit')) f.wpMinoredit.checked=false;
    f.wpWatchthis.checked=false ;
    f.wpTextbox1.focus();
    if (f.wpTextbox1.scrollTop || true) f.wpTextbox1.scrollTop = f.wpTextbox1.scrollHeight ;
 }
 
 function whackSelf   (x) { whackEdit ("{{subst:uw-selfrevert|}} ~~~~",   "{{subst:uw-selfrevert}} ~~~~","Self-reverted test", 0); }
 function whackWarn   (x) { whackEdit ("{{subst:uw-test"+x+"|}} ~~~~",    "{{subst:uw-test"+x+"}} ~~~~",      "Experimenting", x); }
 function whackVandal (x) { whackEdit ("{{subst:uw-vand"+x+"|}} ~~~~",    "{{subst:uw-vand"+x+"}} ~~~~",   "Vandalizing", x); }
 function whackBlank  (x) { whackEdit ("{{subst:uw-delete"+x+"|}} ~~~~",  "{{subst:uw-delete"+x+"}} ~~~~", "Blanking", x); }
 function whackErrors (x) { whackEdit ("{{subst:uw-error"+x+"|}} ~~~~",   "{{subst:uw-error"+x+"}} ~~~~",  "Introducing errors", x); }
 function whackNPOV   (x) { whackEdit ("{{subst:uw-npov"+x+"|}} ~~~~",    "{{subst:uw-npov"+x+"}} ~~~~", "[[WP:NPOV|NPOV]]", x); }
 function whackNOR    (x) { whackEdit ("{{subst:uw-nor"+x+"|}} ~~~~",     "{{subst:uw-nor"+x+"}} ~~~~", "[[WP:NOR|Original research issues]]", x); }
 function whackBLP    (x) { whackEdit ("{{subst:uw-biog"+x+"|}} ~~~~",    "{{subst:uw-biog"+x+"}} ~~~~", "[[WP:BLP|Living persons issues]]", x); }
 function whackSpam   (x) { whackEdit ("{{subst:uw-spam"+x+"|}} ~~~~",    "{{subst:uw-spam"+x+"}} ~~~~", "Spamming", x); }
 function whackAds    (x) { whackEdit ("{{subst:uw-ad"+x+"|}} ~~~~",      "{{subst:uw-ad"+x+"}} ~~~~", "Advertising", x); }
 function whackCopyvio(x) { whackEdit ("{{subst:uw-copyright|}} ~~~~",    "{{subst:uw-copyright}} ~~~~","Copyright violation", 0); }
 function whackHoax   (x) { whackEdit ("{{subst:uw-hoax|}} ~~~~",         "{{subst:uw-hoax}} ~~~~","Hoax", 0); }
 function whackBlatant(x) { whackEdit ("{{subst:uw-bv|}} ~~~~",           "{{subst:uw-bv}} ~~~~","Blatant vandalism", 0); }
 function whackBlocked(x) { whackEdit ("{{subst:uw-block"+x+"|sig=~~~~}}",  "", "** BLOCKED **", x); }
 
 function whackBlocked2(){whackEdit ("[[Image:Modern_clock_chris_kemps_01.png|left|32px]]"
      + "You have been temporarily [[Wikipedia:Blocking policy|blocked from editing]] because of your disruptive edits."
      + " You are [[Wikipedia:Contributing to Wikipedia|invited to contribute]]"
      + " in a [[Wikipedia:Five pillars|constructive manner]] as soon as the block expires.", "", "Blocked"); }
 
 // **************************************************
 // Installation
 // **************************************************
 
 window.whack_addlilink=function(tabs, n, url, name, id, title, key){
    var ix ;
    var li = document.createElement('li');
    if (n > 0) {
            li.appendChild(document.createTextNode(name)) ;
            for (ix = 1 ; ix <= n ; ix++) {
                    var na = document.createElement('a');
                    na.href = url.replace(/XX/g, ix) ;
                    na.appendChild(document.createTextNode(" "+ix));
                    li.appendChild(na);
            }
    } else {
      var na = document.createElement('a');
      na.href = url;
      na.appendChild(document.createTextNode(name));
      li.appendChild(na);
    }
    if(id) li.id = id;
    tabs.appendChild(li);
    if(id) {
      if(key && title) ta[id] = [key, title];
      else if(key)     ta[id] = [key, ''];
      else if(title)   ta[id] = ['', title];
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    // ?? akeytt();
    return li;
 }
 
 window.whack_addToolboxLink=function(n, url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    whack_addlilink(tb, n, url, name, id);
 }
 
 window.playWhackMoles=function() {
 
  if (document.title.match("Editing User talk:") || document.title.match("Creating User talk:") ) {
 
    whack_addlilink (document.getElementById('p-tb').getElementsByTagName('ul')[0],
         0, "http://en.wikipedia.org/wiki/Wikipedia:Template_messages/User_talk_namespace#Multi_level_templates",
         "Warning Templates:", "uTemplates") ;
 
    whack_addToolboxLink(3, 'javascript:{whackWarn(XX);};void(0);',    'Test',      'toolbox_test');
    whack_addToolboxLink(1, 'javascript:{whackSelf(XX);};void(0);',    'Self Test', 'toolbox_selftest');
    whack_addToolboxLink(4, 'javascript:{whackVandal(XX);};void(0);',  'Vandal',    'toolbox_vandal');
    whack_addToolboxLink(4, 'javascript:{whackBlank(XX);};void(0);',   'Blank',     'toolbox_dele');
    whack_addToolboxLink(3, 'javascript:{whackErrors(XX);};void(0);',  'Errors',    'toolbox_errors');
    whack_addToolboxLink(4, 'javascript:{whackNPOV(XX);};void(0);',    'NPOV',      'toolbox_npov');
    whack_addToolboxLink(4, 'javascript:{whackNOR(XX);};void(0);',     'O.R.',      'toolbox_nor');
    whack_addToolboxLink(4, 'javascript:{whackBLP(XX);};void(0);',     'BLP',       'toolbox_blp');
    whack_addToolboxLink(4, 'javascript:{whackSpam(XX);};void(0);',    'Spam',      'toolbox_spam');
    whack_addToolboxLink(4, 'javascript:{whackAds(XX);};void(0);',     'Ads',       'toolbox_ads');
    whack_addToolboxLink(1, 'javascript:{whackCopyvio(XX);};void(0);', 'Copyright', 'toolbox_copyvio');
    whack_addToolboxLink(1, 'javascript:{whackBlatant(XX);};void(0);', 'Blatant',   'toolbox_blatant');
    whack_addToolboxLink(3, 'javascript:{whackBlocked(XX);};void(0);', 'BLOCK',     'toolbox_block');
  } else {
    whack_addToolboxLink(0, 'javascript:{whackGoogleLookup();};void(0);', 'Google', 'toolbox_googlelookup');
  }
 }
 
 // onload
 window.simpleAddOnload=function(f) {
   if (window.addEventListener) window.addEventListener("load", f, false);
   else if (window.attachEvent) window.attachEvent("onload",f);
 }
 
 
 simpleAddOnload(playWhackMoles);
 
 // </nowiki></pre>
 
/* If you want to use this script, simply add the following line to your monobook.js:

importScript('User:Anomie/useridentifier.js'); // Linkback: [[User:Anomie/useridentifier.js]]

* (Please keep the comment so I can see how many people use this).
*/

var UserIdentifier={
    images:{
        '**':'//upload.wikimedia.org/wikipedia/commons/thumb/7/77/Wikipedia_svg_logo.svg/20px-Wikipedia_svg_logo.svg.png',
        'bot':'//upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Crystal_Clear_action_run.png/20px-Crystal_Clear_action_run.png',
        'sysop':'//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Mop.svg/20px-Mop.svg.png',
        'bureaucrat':'//upload.wikimedia.org/wikipedia/commons/thumb/a/ac/Human-preferences-desktop.svg/20px-Human-preferences-desktop.svg.png',
        'checkuser':'//upload.wikimedia.org/wikipedia/commons/thumb/1/1e/Gnome-searchtool.svg/20px-Gnome-searchtool.svg.png',
        'reviewer':'//upload.wikimedia.org/wikipedia/commons/thumb/a/a0/Wikipedia_Reviewer.svg/20px-Wikipedia_Reviewer.svg.png',
        'accountcreator':'//upload.wikimedia.org/wikipedia/commons/thumb/5/5a/Wikipedia_Accountcreators_v2.svg/20px-Wikipedia_Accountcreators_v2.svg.png',
        'oversight':'//upload.wikimedia.org/wikipedia/commons/thumb/0/06/Oversight_logo.png/20px-Oversight_logo.png',
        'rollbacker':'//upload.wikimedia.org/wikipedia/commons/thumb/d/df/Wikipedia_Rollback.svg/20px-Wikipedia_Rollback.svg.png',
        'filemover':'//upload.wikimedia.org/wikipedia/commons/thumb/8/8d/Wikipedia_File_mover.svg/20px-Wikipedia_File_mover.svg.png',
        'autoreviewer':'//upload.wikimedia.org/wikipedia/commons/thumb/a/a2/Wikipedia_Autopatrolled.svg/20px-Wikipedia_Autopatrolled.svg.png',
        'abusefilter':'//upload.wikimedia.org/wikipedia/commons/thumb/6/64/Wikipedia-Crystal_clear-advancedsetting.png/20px-Wikipedia-Crystal_clear-advancedsetting.png',
        'templateeditor':'//upload.wikimedia.org/wikipedia/commons/thumb/4/41/Wikipedia_Template_editor_icon_%281%29.svg/20px-Wikipedia_Template_editor_icon_%281%29.svg.png',
        'massmessage-sender':'//upload.wikimedia.org/wikipedia/commons/thumb/d/d5/Wikipedia_mass_messenger.svg/20px-Wikipedia_mass_messenger.svg.png'
    },
    gimages:{
        'steward':'//upload.wikimedia.org/wikipedia/commons/thumb/7/75/Wikimedia_Community_Logo.svg/20px-Wikimedia_Community_Logo.svg.png',
        'Global_rollback': '//upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Meta-Wiki_Global_rollback-2000px.png/20px-Meta-Wiki_Global_rollback-2000px.png',
        'global-rollbacker': '//upload.wikimedia.org/wikipedia/commons/thumb/a/a1/Meta-Wiki_Global_rollback-2000px.png/20px-Meta-Wiki_Global_rollback-2000px.png',
        'global-sysop' : '//upload.wikimedia.org/wikipedia/commons/thumb/5/57/Meta-Wiki_Global_sysop-2000px.png/20px-Meta-Wiki_Global_sysop-2000px.png',
        'Global_sysops' : '//upload.wikimedia.org/wikipedia/commons/thumb/5/57/Meta-Wiki_Global_sysop-2000px.png/20px-Meta-Wiki_Global_sysop-2000px.png'
    },

    make_callback:function(name){
        var users=null;
        var globaluserinfo=null;
        var lastedit=null;
        return function(r){
            if(!r.query) throw new Error('Bad response');
            if(r.query.users){
                if(r.query.users.length!=1) throw new Error('Bad response');
                users=r.query.users[0];
            }
            if(r.query.usercontribs){
                lastedit=r.query.usercontribs.length?r.query.usercontribs[0].timestamp:'never';
            }
            if(r.query.globaluserinfo){
                globaluserinfo=r.query.globaluserinfo;
            }
            if(!users || !globaluserinfo || !lastedit) return;
            r=users;
            if(r.name!=name) return;
            r.emailable=(typeof(r.emailable)!='undefined');
            var d=document.createElement('DIV');
            var d2=document.createElement('DIV');
            d2.style.position='relative';
            d2.style.display='inline-block';
            d2.style.styleFloat='left';
            d2.style.overflow='visible';
            d2.style.cursor='pointer';
            d2.style.zIndex=101;
            d2.className='metadata';
            d2.title='Registered: '+r.registration+'\nLast edit: '+lastedit+'\nEdits: '+r.editcount+'\nEmailable: '+(r.emailable?'yes':'no')+'\nGender: '+r.gender;
            d2.onclick=function(){ d.style.display=d.style.display?'':'none'; };
            d.style.display='none';
            d.style.position='absolute';
            d.style.background='#eef';
            d.style.border='1px solid black';
            d.style.padding='3px';
            d.style.zIndex=1000;
            d.appendChild(document.createTextNode('Registered: '+r.registration));
            d.appendChild(document.createElement('BR'));
            d.appendChild(document.createTextNode('Last edit: '+lastedit));
            d.appendChild(document.createElement('BR'));
            d.appendChild(document.createTextNode('Edits: '+r.editcount));
            d.appendChild(document.createElement('BR'));
            d.appendChild(document.createTextNode('Emailable: '+(r.emailable?'yes':'no')));
            d.appendChild(document.createElement('BR'));
            d.appendChild(document.createTextNode('Gender: '+r.gender));
            if(r.groups && r.groups.length>0){
                d.appendChild(document.createElement('BR'));
                d.appendChild(document.createTextNode('Groups: '+r.groups.join(', ')));
                for(var j=r.groups.length-1; j>=0; j--){
                    if(UserIdentifier.images[r.groups[j]]){
                        var i=document.createElement('IMG');
                        i.src=UserIdentifier.images[r.groups[j]];
                        i.width=20;
                        i.height=20;
                        i.style.cursor='pointer';
                        i.title=r.groups[j];
                        d2.appendChild(i);
                    }
                }
                d2.title+='\nGroups: '+r.groups.join(', ');
            }
            if(globaluserinfo.groups && globaluserinfo.groups.length>0){
                d.appendChild(document.createElement('BR'));
                d.appendChild(document.createTextNode('Global groups: '+globaluserinfo.groups.join(', ')));
                for(var j=globaluserinfo.groups.length-1; j>=0; j--){
                    if(UserIdentifier.gimages[globaluserinfo.groups[j]]){
                        var i=document.createElement('IMG');
                        i.src=UserIdentifier.gimages[globaluserinfo.groups[j]];
                        i.width=20;
                        i.height=20;
                        i.style.cursor='pointer';
                        i.title=globaluserinfo.groups[j];
                        d2.appendChild(i);
                    }
                }
                d2.title+='\nGlobal groups: '+globaluserinfo.groups.join(', ');
            }
            if(!d2.firstChild){
                var i=document.createElement('IMG');
                i.src=UserIdentifier.images['**'];
                i.width=20;
                i.height=20;
                i.style.cursor='pointer';
                d2.appendChild(i);
            }
            var i=document.createElement('SPAN');
            i.style.fontSize='16px';
            if(r.gender=='male'){
                i.appendChild(document.createTextNode('♂'));
                i.style.color='#89CFF0';
            } else if(r.gender=='female'){
                i.appendChild(document.createTextNode('♀'));
                i.style.color='#F4C2C2';
            }
            if(i.firstChild) d2.insertBefore(i, d2.firstChild);
            d.onclick=function(){ d.style.display='none'; };
            var h=document.getElementById('firstHeading')
            h.insertBefore(d2,h.firstChild);
            h.parentNode.insertBefore(d,h.nextSibling);
            if(window.CascadeTopicons) CascadeTopicons();
        };
    },

    IDUser:function(name){
        mw.loader.using('mediawiki.util', function(){
            name = decodeURIComponent(name).replace(/_/g, ' ');
            var cb=UserIdentifier.make_callback(name);
            $.ajax({
                url:mw.util.wikiScript('api'),
                dataType:'json',
                type:'POST',
                data:{
                    format:'json',
                    action:'query',
                    list:'users',
                    ususers:name,
                    usprop:'editcount|groups|registration|emailable|gender',
                    meta:'globaluserinfo',
                    guiuser:name,
                    guiprop:'groups'
                },
                success:cb,
                error:function(xhr,textStatus,errorThrown){
                    throw new Error('AJAX error: '+textStatus+' '+errorThrown);
                }
            });
            $.ajax({
                url:mw.util.wikiScript('api'),
                dataType:'json',
                type:'POST',
                data:{
                    format:'json',
                    action:'query',
                    list:'usercontribs',
                    ucuser:name,
                    ucprop:'timestamp',
                    uclimit:1
                },
                success:cb,
                error:function(xhr,textStatus,errorThrown){
                    throw new Error('AJAX error: '+textStatus+' '+errorThrown);
                }
            });
            mw.util.addPortletLink('p-cactions',mw.util.wikiScript()+'?title=Special%3AContributions&target='+encodeURIComponent(name),'Contribs');
            mw.util.addPortletLink('p-cactions',mw.util.wikiScript()+'?title=Special%3ACentralAuth/'+encodeURIComponent(name),'SUL');
        });
    },
 
    onLoad:function(){
        if(mw.config.get('wgNamespaceNumber')==2 || mw.config.get('wgNamespaceNumber')==3){ 
            var u=mw.config.get('wgTitle');
            var i=u.indexOf('/');
            if(i>0) u=u.substr(0,i);
            UserIdentifier.IDUser(u);
        } else if(mw.config.get('wgCanonicalNamespace')=='Special' && mw.config.get('wgCanonicalSpecialPageName')=='Contributions'){
            var a=document.getElementById('contentSub').getElementsByTagName('A')[0].href;
            var u=a.match(/\/wiki\/User:([^\/]+)/);
            if(u) UserIdentifier.IDUser(u[1]);
            u=a.match(/[?&]title=User:([^&]+)/);
            if(u) UserIdentifier.IDUser(u[1]);
        } else if(mw.config.get('wgCanonicalNamespace')=='Special' && mw.config.get('wgCanonicalSpecialPageName')=='Log'){
            var u=['',document.getElementById('mw-log-user').defaultValue];
            if(!u[1]) u=document.getElementById('mw-log-page').defaultValue.match(/^User:([^\/]+)/);
            if(u) UserIdentifier.IDUser(u[1]);
        }
    }
};

$(document).ready(UserIdentifier.onLoad);

/* User:Cumbril/IPLabeller.js */
importScript( 'User:Cumbril/IPLabeller.js' );// Backlink: [[User:Cumbril/IPLabeller.js]]

importScript("User:Jfmantis/pagesCreated.js"); // [[User:Jfmantis/pagesCreated.js]]

/* User:Equazcion/DynaThank.js */
importScript( 'User:Equazcion/DynaThank.js' );// Backlink: [[User:Equazcion/DynaThank.js]]

// <nowiki>
// Script:         MoreMenu.js
// Authors:        MusikAnimal, Haza-w
// Documentation:  [[User:MusikAnimal/MoreMenu]], [[User:Haza-w/Drop-down menus]]
//

mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');
// </nowiki>

importScript('User:GregU/dashes.js'); //[[User:GregU/dashes.js]]

// [[User:Ais523/votesymbols.js]]
// Code for adding icons to !votes in AfDs, RfAs, etc.. Doesn't affect the page, just
// shows the icons when this code is installed.
// Please see [[:Image:Votesymbols.js-enhanced_SfD.png]] for copyright info on the images that are added.

function lowerNoPunct(s)
{
  return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}

$(function() {
  if(wgNamespaceNumber===0) return; //avoid article space, generally speaking
  var vs=
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/15px-Symbol_keep_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_delete_vote.svg/15px-Symbol_delete_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/15px-Symbol_merge_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/15px-Symbol_move_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/15px-Symbol_redirect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/15px-Symbol_opinion_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_comment_vote.svg/15px-Symbol_comment_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/15px-Symbol_unsupport_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/15px-Symbol_question.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Symbol_divide_vote.svg/15px-Symbol_divide_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/15px-Symbol_wait.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Face-grin.svg/15px-Face-grin.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Symbol_support2_vote.svg/15px-Symbol_support2_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/15px-Symbol_no_support_vote.svg.png";
  var vt=vs.split("#");
  var la=[];
  la['support']=0; la['endorse']=0;
  la['keep']=1; la['allow']=1;
  la['oppose']=2; la['overturn']=2; la['object']=2;
  la['delete']=3;
  la['neutral']=4;
  la['merge']=5; la['upmerge']=5;
  la['move']=6; la['rename']=6; la['userfy']=6; la['transwiki']=6; la['listify']=6;
  la['redirect']=7; la['retarget']=7;
  la['opinion']=8; la['relist']=8; la['subst']=8; la['salt']=8; la['change']=8; la['list']=8;
  // Note that icon 8 on the list is often used for debate-specific !votes
  la['comment']=9; la['update']=9; la['note']=9;
  la['delist']=10;
  la['question']=11;
  la['split']=12;
  la['wait']=13;
  la['bjaodn']=14;
  la['undelete']=15; la['restore']=15;
  la['close']=16;
 
  var btc=document.body.getElementsByTagName("B");
  i=btc.length;
  while(i--)
  {
    var j,k;
    j=btc[i].innerHTML.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
    k=0;
    var x="";
    while(k<j.length)
    {
      if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
       ||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;
      var l=la[lowerNoPunct(j[k])];
      if(l!==undefined)
      {
        x+='<img src="'+vt[l]+'" alt="" /> '
      }
      k++;
    }
    if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML;
  }
});
//[[Category:Wikipedia scripts]]