Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
//<pre><nowiki>
/**********************************
 *  EasyBlock v2.5                *
 **********************************
 *  By Animum                     *
 ***************************************************************************************
 *  To use this script, add the following line to your monobook (or other skin) file:  *
 
    importScript("User:Animum/easyblock.js"); //[[User:Animum/easyblock.js]]
 ***************************************************************************************/
 
/*********************************
 *  Handy-dandy block script     *
 *********************************
 *  Code originally adapted from *
 *  scripts by DerHexer and      *
 *  Voice of All, but I have     *
 *  significantly rewritten it   *
 *  since then.                  *
 *********************************
 *  This script has only been    *
 *  tested in Firefox. It may    *
 *  not work in other browsers.  *
 *********************************/
 
/* Libraries that support this script */
importScript('User:Animum/urlparameters.js');
importStylesheet('User:Animum/easyblock.css');
 
function easyblock() {} //So we can have some sanity in the arrangement of this
 
easyblock.addlilink = function(tabs, href, name, id, title, key){
    var na = document.createElement('a');
    na.href = href;
    na.appendChild(document.createTextNode(name));
    na.style.cssText = 'cursor:pointer';
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    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;
}
 
easyblock.addlimenu = function(tabs, name, id, href, position) {
    var na, mn;
    var li;
 
    if (!id)  id = name;
 
    na = document.createElement("a");
    na.appendChild(document.createTextNode(name));
    na.onclick = href;
    na.style.cssText = 'cursor:pointer';
    mn = document.createElement("ul");
    li = document.createElement("li");
    li.appendChild(na);
    li.appendChild(mn);
    if (id) li.id = id;
    li.className = 'blockmenu';
 
    if (position) {
        tabs.insertBefore(li, position);
    } else {
        tabs.appendChild(li);
    }
 
    return mn;  // useful because it gives us the <ul> to add <li>s to
}
 
easyblock.makeMenu = function(where, id, items) {
    if(typeof(id) == 'undefined') id = "submenu";
    var ul = document.createElement("ul");
    ul.className = "blockmenu";
    ul.id = id;
    where.appendChild(ul);
    with(ul.style) {
        left = "114px";
        top = "-1px";
        display = "none";
    }
    for(i=0; i<items.length; i++) {
        var item = items[i];
        easyblock.addlilink(document.getElementById(id), item[0], item[1], (typeof(item[2]) != 'undefined' ? item[2] : ""));
    }
    where.onmouseover = function() {
        ul.style.display = "block";
    }
    where.onmouseout = function() {
        ul.style.display = "none";
    }
}
 
easyblock.zeroPad = function(str) {
 return ("0" + str).slice(-2);
}
 
easyblock.formatResponse = function(response) { //This bit was stolen from Gracenotes.  Thanks, Gracenotes!
    try {
        response = response.query.pages;
        for (var property in response)
            return response[property];
    } catch (e) {
        return response.query.pages[-1];
    }
}
 
easyblock.textUpdate = function(message, br) {
    if(typeof(br) == 'undefined') br = true;
    document.getElementById("contentSub").innerHTML += (br ? "<br />" : "") + "<b>" + message + "</b>";
}
 
easyblock.bgColor = function(color) {
    document.getElementById("content").style.backgroundColor = color;
}
 
easyblock.isIP = function(ip) { 
    return /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/.test(ip);
}
 
easyblock.isSensitive = function(address) { //Stolen from [[MediaWiki:Sysop.js]].
    ips = Array(
        Array(/\b63\.162\.143\.21\b/),
        Array(/\b82\.148\.9(6\.68|7\.69)\b/),
        Array(/\b128\.183\.103\.97\b/),
        Array(/\b(((2|5)?6|7|[12]1|2(2|8|9)|3(0|3)|55)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))|130\.22)(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/),
        Array(/\b138\.16[23](\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/),
        Array(/\b143\.2(2[89]|3[01])(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/),
        Array(/\b149\.101(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/),
        Array(/\b156\.33(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}\b/),
        Array(/\b(162\.4[56]\.([01]?\d\d?|2(5[0-5]|[0-4]\d))|198\.81\.(128|129|1[3-8]\d|191))\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/),
        Array(/\b192\.197\.(7[7-9]|8[0-6])\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/),
        Array(/\b(51(\.([01]?\d\d?|2(5[0-5]|[0-4]\d))){2}|194.60.\d[0-5]?)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/),
        Array(/\b66\.230\.(19[2-9]|2[0-3]\d)\.([01]?\d\d?|2(5[0-5]|[0-4]\d))\b/),
        Array(/\b91\.198\.174\.(19[2-9]|2([01]\d|2[0-3]))\b/)
    );
    ip = address;
    if (this.isIP(ip)) {
        for (i = 0; i < ips.length; i++) {
            if (ip.match(ips[i][0])) {
                return true;
            } else {
                return false;
            }
        }
    }
}
/* End of library section */
 
//I authored (most of) what is below.
//-----------------------------------
//Preferences
if(typeof(ebPrefs) == 'undefined') {
    ebPrefs = {};
}
 
if(typeof(ebPrefs.markWarnAsMinor) == 'undefined') {
    ebPrefs.markWarnAsMinor = 1;
}
 
if(typeof(ebPrefs.showOnPages) == 'undefined') {
    ebPrefs.showOnPages = ["user_usertalk", "contribs", "diffs", "ipblocklist", "blockip"];
}
 
if(typeof(ebPrefs.useAutoWarn) == 'undefined') {
    ebPrefs.useAutoWarn = true;
}
 
if(typeof(ebPrefs.loadCommentOnSubmit) == 'undefined') {
    ebPrefs.loadCommentOnSubmit = true;
}
 
if(typeof(ebPrefs.displayStatus) == 'undefined') {
    ebPrefs.displayStatus = true;
}
 
if(typeof(ebPrefs.watchlistEnabled) == 'undefined') {
    ebPrefs.watchlistEnabled = false;
}

if(typeof(ebPrefs.showOnClick) == 'undefined') {
    ebPrefs.showOnClick = false;
}
//End of Preferences section.
 
easyblock.canShowOn = function(pgName) { //For reading the ebPrefs.showOnPages data
    return (ebPrefs.showOnPages.indexOf(pgName) != -1 ? true : false);
}
 
easyblock.isBlocked = function(name) {
    var req = sajax_init_object();
    req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=blocks&bkusers=" + name + "&format=json", false);
    req.send(null);
    var info = eval("(" + req.responseText + ")");
    return (info.query.blocks[0] ? true : false);
    delete req;
}
 
easyblock.userBlocked = function(name) {
    var req = sajax_init_object();
    req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&list=blocks&bkusers=" + name + "&format=json&bkprop=by", false);
    req.send(null);
    var info = eval("(" + req.responseText + ")");
    return (unescape(info.query.blocks[0].by) == wgUserName ? true : false);
    delete req;
}
 
easyblock.warn = function(page, comment, summary, replacePage, loadCommentOnSubmit) {
    if(typeof(loadCommentOnSubmit) == 'undefined') loadCommentOnSubmit = true;
    page = decodeURIComponent(page);
    var req = sajax_init_object();
    req.open("GET", "http://en.wikipedia.org/w/api.php?action=query&prop=info|revisions&format=json&intoken=edit&rvprop=content|timestamp&titles=" + encodeURIComponent(page), false);
    if(ebPrefs.dislayStatus) this.textUpdate("Adding \"" + comment + "\" to <a href=\"http://en.wikipedia.org/wiki/" + encodeURIComponent(page) + "\">" + page + "</a>...");
    req.send(null);
 
    var info = this.formatResponse(eval("(" + req.responseText + ")"));
    var date = new Date();
    var startTime = date.getUTCFullYear() + this.zeroPad(date.getUTCMonth() + 1) + this.zeroPad(date.getUTCDate()) + this.zeroPad(date.getUTCHours()) + this.zeroPad(date.getUTCMinutes()) + this.zeroPad(date.getUTCSeconds());
    var editTime = (info.revisions ? info.revisions[0].timestamp.replace(/[^0-9]/g, "") : startTime); 
    var content = (info.revisions ? (info.revisions[0]["*"].length > 0 ? info.revisions[0]["*"] : "") : "");
    var editToken = info.edittoken;
 
    var postdata = 'title=' + encodeURIComponent(page)
                 + '&action=submit'
                 + '&wpTextbox1=' + (replacePage == true ? encodeURIComponent(comment) : encodeURIComponent(content + (content.length > 0 ? "\n\n" : "") + comment))
                 + '&wpSummary=' + encodeURIComponent(summary)
                 + '&wpSave=save'
                 + '&wpEditToken=' + encodeURIComponent(editToken)
                 + '&wpEdittime=' + editTime
                 + '&wpStarttime=' + startTime
                 + (ebPrefs.markWarnAsMinor == 1 ? "&wpMinoredit=1" : "")
                 + (ebPrefs.watchlistEnabled ? "&wpWatchthis=1" : "");
 
    delete req;
    var req = sajax_init_object();
    req.open("POST", wgScript, true);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.setRequestHeader("Content-length", postdata.length);
    req.onreadystatechange = function() {
        if(req.readyState == 4 && req.status == 200) {
            easyblock.bgColor("#EEF"); //We're done.
            if(ebPrefs.displayStatus) easyblock.textUpdate(" done!", false);
            if(loadCommentOnSubmit && ebPrefs.loadCommentOnSubmit) {
                window.setTimeout(function() { location.href = "http://en.wikipedia.org/wiki/" + encodeURIComponent(page); }, 2000);
            }
        }
    };
    req.send(postdata);
    delete req;
}
 
easyblock.warnAndTag = function(page, comment, summary, replacePage, page2, comment2, summary2, replacePage2) {
    this.warn(page, comment, summary, replacePage, false);
    this.warn(page2, comment2, summary2, replacePage2);
}
 
easyblock.block = function(name, reason, duration, enableAutoblock, createAccount, emailBan, allowusertalk, anononly) {
    //Safeguards against errors
    if(this.isBlocked(name)) {
        document.getElementById("contentSub").innerHTML += "<br />";
        this.textUpdate("Error:  " + name + " is already blocked. (<a href=\"http://en.wikipedia.org/w/index.php?title=Special:IPBlockList&action=unblock&ip=" + name + "\">unblock</a>)");
        return;
    } 
    if(this.isSensitive(name)) {
        document.getElementById("contentSub").innerHTML += "<br />";
        this.textUpdate("Aborting:  " + name + " is marked as a sensitive address.");
        return;
    }
    if(typeof(name) == "undefined") {
        document.getElementById("contentSub").innerHTML += "<br />";
        this.textUpdate("Error:  No username was specified; please block manually.  If this problem persists across many pages, <a href=\"http://en.wikipedia.org/w/index.php?title=User_talk:Animum&action=edit&section=new\">contact Animum</a>.");
        return;
    }
    if(name == wgUserName) {
        var confirmBlock = confirm("Do you really want to block yourself?\n\n(Click \"Yes\" to proceed, \"no\" to abort.)");
        if(!confirmBlock) {
            this.textUpdate("Aborted.");
            return;
        }
    }
    if(!reason) {
        document.getElementById("contentSub").innerHTML += "<br />";
        this.textUpdate("Error:  No reason was specified; please block manually.  If this problem persists across many pages, <a href=\"http://en.wikipedia.org/w/index.php?title=User_talk:Animum&action=edit&section=new\">contact Animum</a>.");
        return;
    }
    if(!duration) {
        document.getElementById("contentSub").innerHTML += "<br />";
        this.textUpdate("Error:  No duration was specified; please block manually.  If this problem persists across many pages, <a href=\"http://en.wikipedia.org/w/index.php?title=User_talk:Animum&action=edit&section=new\">contact Animum</a>.");
        return;
    }
    //If none of these safeguards have been triggered, continue.
    if(ebPrefs.displayStatus) document.getElementById("contentSub").innerHTML += "<br />";
    this.bgColor("#EFE"); //Begin.
    var req = sajax_init_object();
    req.open("POST", wgScriptPath + "/api.php", false);
    req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    req.send("format=json&action=block&gettoken=1&user=" + name); //Fancy fluff that gets an arbitrary-looking string to submit to index.php
 
    var edittoken = eval("(" + req.responseText + ")").block.blocktoken;
    delete req;
    if(typeof(allowusertalk) == "undefined") {
        allowusertalk = 1;
    }
    if(reason.indexOf("sockpuppet") != -1) {
        sockof = prompt("Name of master account:");
        if(!sockof) return;
        reason = (reason.indexOf("confirmed") != -1 ? "Confirmed" : "Suspected") + " \[\[Wikipedia:Sock puppetry\|sock puppet\]\] of \[\[User:" + sockof + "\|" + sockof + "\]\]" + (reason.indexOf("confirmed") != -1 ? " (\[\[Wikipedia:Sockpuppet investigations/" + sockof + "\|investigation\]\])" : "");
    }
    if(duration == "indefinite") { //0 means false; 1 means true.
        if(reason != "{{uw-ublock}}") {
            createAccount = typeof(createAccount) == "undefined" ? 1 : createAccount;
            enableAutoblock = typeof(enableAutoblock) == "undefined" ? 1 : enableAutoblock;
        } else {
            createAccount = typeof(createAccount) == "undefined" ? 0 : createAccount;
            enableAutoblock = typeof(enableAutoblock) == "undefined" ? 0 : enableAutoblock;
        }
    } else { 
        createAccount = typeof(createAccount) == "undefined" ? 1 : createAccount;
        enableAutoblock = typeof(enableAutoblock) == "undefined" ? 1 : enableAutoblock;
    }
 
    var postdata = "title=Special:Block"
                 + "&action=submit"
                 + "&wpBlockAddress=" + encodeURIComponent(name)
                 + "&wpBlockOther=" + encodeURIComponent(duration)
                 + "&wpBlockReason=" + encodeURIComponent(reason)
                 + "&wpBlockReasonList=other"
                 + "&wpCreateAccount=" + createAccount
                 + (this.isIP(name) ? "&wpAnonOnly=" + (anononly || 1) : "&wpEnableAutoblock=" + enableAutoblock)
                 + "&wpAllowUsertalk=" + allowusertalk
                 + "&wpEmailBan=" + (emailBan || 0)
                 + "&wpEditToken=" + encodeURIComponent(edittoken)
                 + "&wpBlock=block";
    var req = sajax_init_object();
    req.open("POST", wgScript, false);
    req.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
    req.setRequestHeader('Content-length', postdata.length);
    req.send(postdata);
    delete req;
    if(this.userBlocked(name)) { //Make sure we really are done.
        if(ebPrefs.displayStatus) this.textUpdate(name + " has been blocked.");
        if(ebPrefs.useAutoWarn == true) {
            if(reason.indexOf("sock puppet") != -1) {
                this.warnAndTag("User talk:" + name, "\{\{subst\:sockblock\|" + sockof + "\}\} \~\~\~\~", "You are" + (reason.indexOf("Suspected") != -1 ? " suspected of being" : "") + " a sockpuppet of \[\[User\:" + sockof + "\|" + sockof + "\]\] and have been blocked indefinitely.", false, "User:" + name, (reason.indexOf("Suspected") != -1 ? "\{\{sockpuppet\|" + sockof + "\|blocked\}\}" : "\{\{CheckedSockpuppet\|" + sockof + "\|" + sockof + "\}\}"), "You are" + (reason.indexOf("Suspected") != -1 ? " suspected of being" : "") + " a sockpuppet of \[\[User\:" + sockof + "\|" + sockof + "\]\] and have been blocked indefinitely.", true);
            }
            if(reason == "[[Wikipedia:Vandalism|Vandalism]]") {
                this.warn("User talk:" + name, "\{\{subst\:uw-vblock\|time=" + duration + "\|subst\=subst\:\|sig\=y\}\}", "Due to recent \[\[Wikipedia\:Vandalism\|vandalism\]\] from this " + (this.isIP(name) ? "IP address" : "account") + ", it has been blocked for " + duration + ".", false);
            }
            if(reason == "{{uw-ublock}}" && !this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{subst:uw-ublock\|sig\=y\|subst\=subst\:\}\}", "You have been blocked for a violation of the \[\[Wikipedia\:Username policy\|username policy\]\].", false);
            }
            if(reason == "{{uw-uhblock}}" && !this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{subst:uw-uhblock\|sig\=y\|subst\=subst\:\}\}", "You have been blocked for an egregious violation of the \[\[Wikipedia\:Username policy\|username policy\]\].", false);
            }
            if(reason == "{{uw-spamublock}}" && !this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{subst:uw-spamublock\|sig\=y\|subst\=subst\:\}\}", "You have been blocked because your username seems to exist only to promote a corporation or group.", false);
            }
            if(reason == "{{schoolblock}}" && this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{schoolblock\|1\=Blocked for " + duration + ".\|sig\=\~\~\~\~}\}", "Due to extensive vandalism from this school's IP address, it has been blocked for " + duration + ".", false);
            }
            if(reason == "{{anonblock}}" && this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{anonblock\|1\=Blocked for " + duration + ".\|sig\=\~\~\~\~}\}", "Due to extensive vandalism from this IP address, it has been blocked for " + duration + ".", false);
            }
            if(reason == "[[Wikipedia:Vandalism|Vandalism]]-only account" && !this.isIP(name)) {
                this.warn("User talk:" + name, "\{\{subst\:uw-voablock\|subst\=subst\:\|sig\=y\}\}", "You have been blocked indefinitely because your account has been used only for \[\[Wikipedia\:Vandalism\|vandalism\]\].", false);
            }
            if(reason == "[[Wikipedia:No personal attacks|Personal attacks]] or [[Wikipedia:Harassment|harassment]]") {
                this.warn("User talk:" + name, "\{\{subst\:uw-hblock\|subst\=subst\:\|sig\=y\}\}", "You have been blocked for harassing or attempting to harass other users.", false);
            }
            if(reason == "Blatant vandalism or harassment") {
                this.bgColor("#EEF");
                if(ebPrefs.displayStatus) this.textUpdate(name + " has been blocked.");
                location.href = "/wiki/User_talk:" + name;
            }
        } else {
            if(ebPrefs.displayStatus) this.textUpdate(name + " has been blocked.");
            this.bgColor("#EEF");
        }
    } else { //Change bgColor when we have nothing else to do
        this.textUpdate("An unknown error has occurred.  Please block manually.");
        this.bgColor("#EEF"); //We're done.
    }
}
 
easyblock.getLastBlock = function(user) {
    var req = sajax_init_object();
    req.open("GET", "http://en.wikipedia.org/w/api.php?format=json&action=query&list=logevents&letype=block&letitle=User:" + user + "&leprop=details", false);
    req.send(null);
    var response = eval("(" + req.responseText + ")");
    if(response.query.logevents[0]) {
        return (this.isBlocked(user) ? "blocked" : "last block") + ": " + response.query.logevents[0].block.duration;
    } else {
        return "not blocked before";
    }
    delete req;
}
 
easyblock.customBlock = function(target) {
    easyblock.customBlock.submit = function() {
        easyblock.block(document.getElementById("targetUser").value, document.getElementById("ebReason").value, document.getElementById("ebExpiry").value, (document.getElementById("ebAutoblock").checked == true ? 1 : 0), (document.getElementById("ebCreateAccount").checked == true ? 1 : 0), (document.getElementById("ebEmailBan").checked == true ? 1 : 0), (document.getElementById("ebAllowUsertalk").checked == true ? 1 : 0), (document.getElementById("ebAnononly").checked == true ? 1 : 0));
        if(document.getElementById("ebTemplate").value.length > 0) easyblock.warn("User talk:" + target, document.getElementById("ebTemplate").value, "You have been blocked for " + document.getElementById("ebExpiry").value + ".", false);
    }
    jsMsg('<table style="font-size:10pt;color:black;background-color:transparent">'
        + '<tr><td>Username:</td><td><input type="text" id="targetUser" name="targetUser" disabled=true value="' + target + '" /></td></tr>'
        + '<tr><td>Expiry:</td><td><input type="text" id="ebExpiry" name="ebExpiry" /></td></tr>'
        + '<tr><td>Reason:</td><td><input type="text" id="ebReason" name="ebReason" /></td></tr>'
        + '<tr><td>Block options:</td></tr>'
            + '<tr><td><td>' + (this.isIP(target) ? '<input type="checkbox" id="ebAnononly" /> Block anonymous users only<input type="checkbox" id="ebAutoblock" style="display:none" />' : '<input type="checkbox" id="ebAnononly" style="display:none" /><input type="checkbox" id="ebAutoblock" checked="true" /> Enable autoblock') + '</td></td></tr>' //Fancy stuff
            + '<tr><td><td>' + (!this.isIP(target) ? '<input type="checkbox" id="ebEmailBan" /> Block user from sending e-mail' : '') + '</td></td></tr>'
            + '<tr><td><td><input type="checkbox" id="ebCreateAccount" /> Block user from creating accounts</td></td></tr>'
            + '<tr><td><td><input type="checkbox" id="ebAllowUsertalk" checked="true" /> Allow user to edit his or her talk page</td></td></tr>'
        + '<tr><br /></tr>'
        + '<tr><td>Template:<sup><b>†</b></sup></td><td><input type="text" id="ebTemplate" name="ebTemplate" /></td></tr>'
        + '<tr><td><input type="button" value="Block" id="blockButton" name="blockButton" onclick="easyblock.customBlock.submit()" /></td></tr>'
        + '</table>'
        + '<br /><sup><b>†</b></sup><small>Optional, but please include all wikimarkup and your signature if you specify it.  For example: <code>&#123;&#123;subst:uw-vblock|time=24 hours|subst=subst:&#125;&#125; &#126;&#126;&#126;&#126;</code></small>'
    );
}
 
easyblock.showTab = function() {
    if(wgNamespaceNumber == 2 || wgNamespaceNumber == 3) {
        if(document.title.indexOf('/') != -1) {
            var targetUser = wgTitle.split('/')[0];
        } else {
            var targetUser = wgTitle;
        }
    }
 
    /* Diffs can be so temperamental */
    if(UrlParameters["diff"] > "") {
        targetUser = document.evaluate('//div[@id="mw-diff-ntitle2"]//a[3]/@title', document, null, XPathResult.STRING_TYPE, null).stringValue.split("/")[1];
    }
 
    if(wgCanonicalSpecialPageName == "Ipblocklist" && window.location.href.indexOf("&action=success&successip=") != -1) {
        var targetUser = document.getElementById("contentSub").getElementsByTagName("a")[0].firstChild.nodeValue;
    }
 
    if(wgPageName=="Special:Contributions") {
        var targetUser = decodeURIComponent(document.evaluate('//div[@id="contentSub"]/a[1]/@href', document, null, XPathResult.STRING_TYPE, null).stringValue.split(":")[1].split("&")[0]).replace(/[+_]/g, " ");
    }
 
    if(wgPageName=="Special:BlockIP") {
        if(window.location.href.indexOf("&action=success") == -1) {
            var targetUser = document.forms["blockip"].elements["wpBlockAddress"].value;
        } else {
            var targetUser = UrlParameters["ip"];
        }
    }
    if(((wgNamespaceNumber == 2 || wgNamespaceNumber == 3) && this.canShowOn("user_usertalk")) || (UrlParameters["diff"] > "" && this.canShowOn("diffs")) || (wgPageName == "Special:Contributions" && this.canShowOn("contribs")) || (wgPageName == "Special:BlockIP" && this.canShowOn("blockip")) || (window.location.href.indexOf("Special:BlockList&action=success&successip=") != -1 && this.canShowOn("ipblocklist"))) {
        if((wgPageName == "Special:BlockIP" && window.location.href.indexOf("&action=success") != -1) || (wgPageName == "Special:BlockIP" && document.forms["blockip"].elements["wpBlockAddress"].value.length == 0)) {
            return;
        } else {
            this.addlimenu(document.getElementById('p-cactions').getElementsByTagName('ul')[0], 'block', 'blockoptions', '');
            var blockoptions = document.getElementById('blockoptions').getElementsByTagName('ul')[0];
            this.addlilink(blockoptions, "/w/index.php?title=Special:Log&page=User:" + targetUser + "&type=block", this.getLastBlock(decodeURIComponent(targetUser)), "");
            this.addlilink(blockoptions, "#", "vandalism »", "ca-vandalblock");
                this.makeMenu(document.getElementById("ca-vandalblock"), "vandalblock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"24 hours\")", "V+24 hours"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"31 hours\")", "V+31 hours"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"48 hours\")", "V+48 hours"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"3 days\")", "V+3 days"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"1 week\")", "V+1 week"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"2 weeks\")", "V+2 weeks"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"1 month\")", "V+1 month"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"3 months\")", "V+3 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"6 months\")", "V+6 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\", \"1 year\")", "V+1 year"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:Vandalism|Vandalism\]\]\-only account\", \"indefinite\")", "Voa+indefinite"]
                ));
            this.addlilink(blockoptions, "#", "schoolblock »", "ca-schoolblock");
                this.makeMenu(document.getElementById("ca-schoolblock"), "schoolblock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"1 week\")", "school+1 week"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"2 weeks\")", "school+2 weeks"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"1 month\")", "school+1 month"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"3 months\")", "school+3 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"6 months\")", "school+6 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{schoolblock\}\}\", \"1 year\")", "school+1 year"]
                ));
            this.addlilink(blockoptions, "#", "anonblock »", "ca-anonblock");
                this.makeMenu(document.getElementById("ca-anonblock"), "anonblock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"1 week\")", "anon+1 week"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"2 weeks\")", "anon+2 weeks"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"1 month\")", "anon+1 month"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"3 months\")", "anon+3 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"6 months\")", "anon+6 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{anonblock\}\}\", \"1 year\")", "anon+1 year"]
                ));
            this.addlilink(blockoptions, "#", "username »", "ca-usernameblock");
                this.makeMenu(document.getElementById("ca-usernameblock"), "usernameblock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{uw-ublock\}\}\", \"indefinite\")", "Name+indefinite"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{uw-uhblock\}\}\", \"indefinite\")", "Hardname+indefinite"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\{\{uw-spamublock\}\}\", \"indefinite\")", "Spamname+indefinite"]
                ));
            this.addlilink(blockoptions, "#", "npa »", "ca-npablock");
                this.makeMenu(document.getElementById("ca-npablock"), "npablock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"1 day\")", "npa+1 day"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"3 days\")", "npa+3 days"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"1 week\")", "npa+1 week"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"2 weeks\")", "npa+2 weeks"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"1 month\")", "npa+1 month"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"3 months\")", "npa+3 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"6 months\")", "npa+6 months"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"1 year\")", "npa+1 year"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"\[\[Wikipedia:No personal attacks\|Personal attacks\]\] or \[\[Wikipedia:Harassment\|harassment\]\]\", \"indefinite\")", "npa+indef"]
                ));
            this.addlilink(blockoptions, "#", "sockpuppet »", "ca-sockblock");
                this.makeMenu(document.getElementById("ca-sockblock"), "sockblock-list", new Array(
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"sockpuppet\", \"indefinite\")", "suspectedsock+indef"],
                    ["javascript:easyblock.block(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"confirmedsockpuppet\", \"indefinite\")", "confirmedsock+indef"]
                ));
            this.addlilink(blockoptions, "javascript:easyblock.block(\"" + encodeURIComponent(targetUser).replace(/_/g, " ") + "\", \"Blatant vandalism or harassment\", \"indefinite\", 1, 1, 1, 0)", "grawp+indef");
            this.addlilink(blockoptions, "javascript:easyblock.customBlock(\"" + decodeURIComponent(targetUser).replace(/_/g, " ") + "\")", 'Custom block');
            if(ebPrefs.showOnClick) {
                var items = getElementsByClassName(document, "li", "blockmenu")[0].getElementsByTagName("ul")[0];
                items.style.display = "none";
                document.getElementById("blockoptions").onclick = function() {
                    items.style.display = (items.style.display == "block" ? "none" : "block");
                }
            }
        }
    }
}
 
function ebShowTab() { //Hacking so that the parent of easyblock.showTab is "easyblock," rather than "window."
    easyblock.showTab();
}
 
if(wgUserGroups.indexOf("sysop") != -1) {
    addOnloadHook(ebShowTab);
}