User:Synergy/easyblock.js
From Wikipedia, the free encyclopedia
//
<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
- to add
- 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 ? "
" : "") + "" + message + ""; } 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%7Crevisions&format=json&intoken=edit&rvprop=content%7Ctimestamp&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 += "
"; 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 += "
"; this.textUpdate("Aborting: " + name + " is marked as a sensitive address."); return; } if(typeof(name) == "undefined") { document.getElementById("contentSub").innerHTML += "
"; 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§ion=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 += "
"; 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§ion=new\">contact Animum</a>."); return; } if(!duration) { document.getElementById("contentSub").innerHTML += "
"; 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§ion=new\">contact Animum</a>."); return; } //If none of these safeguards have been triggered, continue. if(ebPrefs.displayStatus) document.getElementById("contentSub").innerHTML += "
"; 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 != "Your account, Synergy has been blocked from changing Wikipedia because the username may not meet our username policy. This is not anything against you, and you are encouraged to choose a new account name that meets our guidelines. We hope to see you changing again soon!") {- If you feel this block was made wrongly, you may quickly and easily ask to be unblocked.
Our username policy says how you should choose your username. Put simply, you should not have a username that people find offensive, advertises a real world group or company, or is confusing (for example, if it pretends to be another user).
If you have already made changes and wish to keep your changes under a new name you may ask us to rename your account. If you want to, please:
- 1. Ask for an unblock
- Type {{unblock|reason}} on your user talk page which you should still be able to change. You want to change your username, so say that. If an administrator thinks that you should be unblocked, he or she will do so for you, normally for 24 hours.
- 2. Ask for a change in username
- Go here and ask for a new name. A steward or a global renamer will take care of the request.
If you have made very few or no changes, then it would be a lot easier to just create a new account.
Please note that the software Wikipedia uses may automatically block you from creating a new account. This is a mistake, and should not have happened. If this has happened, use the unblock template as explained above, and an administrator will fix it for you.
If you think you should not have been blocked, add {{unblock|your reason here}} on your user talk page or email the administrator who blocked you. You can also send an e-mail to simple-admins-l@lists.wikimedia.org and an administrator will look at your reason and reply.
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 == "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 == "Your account, Synergy has been blocked from changing Wikipedia because the username may not meet our username policy. This is not anything against you, and you are encouraged to choose a new account name that meets our guidelines. We hope to see you changing again soon!" && !this.isIP(name)) {- If you feel this block was made wrongly, you may quickly and easily ask to be unblocked.
Our username policy says how you should choose your username. Put simply, you should not have a username that people find offensive, advertises a real world group or company, or is confusing (for example, if it pretends to be another user).
If you have already made changes and wish to keep your changes under a new name you may ask us to rename your account. If you want to, please:
- 1. Ask for an unblock
- Type {{unblock|reason}} on your user talk page which you should still be able to change. You want to change your username, so say that. If an administrator thinks that you should be unblocked, he or she will do so for you, normally for 24 hours.
- 2. Ask for a change in username
- Go here and ask for a new name. A steward or a global renamer will take care of the request.
If you have made very few or no changes, then it would be a lot easier to just create a new account.
Please note that the software Wikipedia uses may automatically block you from creating a new account. This is a mistake, and should not have happened. If this has happened, use the unblock template as explained above, and an administrator will fix it for you.
If you think you should not have been blocked, add {{unblock|your reason here}} on your user talk page or email the administrator who blocked you. You can also send an e-mail to simple-admins-l@lists.wikimedia.org and an administrator will look at your reason and reply.
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 == "Your account has been blocked indefinitely from changing Wikipedia because it clearly does not meet our username policy – it contains a bad word, attacks or pretends to be another person, or clearly shows that you do not want to make Wikipedia better (see our blocking and username policies for more information). We invite everyone to make changes to Wikipedia that improve it, but users are not allowed to change with bad usernames. We do not allow trolling or other bad behaviour. If you think that this block is unfair, you may ask to be unblocked by adding {{unblock|your reason here}} at the bottom of your talk page. If you cannot do this or the reason is private, please send an e-mail to simple-admins-l@lists.wikimedia.org and an administrator will look at your reason and reply. You may want to read our guide to unblock requests before asking to be unblocked." && !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 == "Your account has been blocked from changing Wikipedia, because it is being used for advertising. See Wikipedia's username policy for more information. This kind of activity is considered spamming, which is not allowed. If you do not agree with this block, please reply on your talk page by adding {{unblock|reason}}, replacing reason with why you think the block is wrong, or send an e-mail to simple-admins-l@lists.wikimedia.org and an administrator will look at your reason and reply." && !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 == "To edit, please make an account at home and log in with it here." && this.isIP(name)) {Due to repeated vandalism (see change log), editing by anonymous users from your school, library or institution's IP address is currently disabled. You can still read the encyclopedia. To stop abuse, account creation using this IP address is probably also disabled.
If editing is required for class projects, please have your teacher or network administrator contact us (with reference to this IP address) at simple-admins-l from an email address listed on your school's website. Alternatively, if you have no Internet access at home, you may email us using your school's email address, telling us which username you would like. An account will be made for you. Please check this list that the user name you chose has not already been taken.
Thank you.
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 == "
To change pages, please log in.
Changing pages by anonymous users from your shared IP address or address range may be currently disabled. Registered users, however, are still able to change. If you are currently blocked from creating an account, you may ask to be unblocked or send an e-mail to simple-admins-l@lists.wikimedia.org and an administrator will look at your reason and reply.
When contacting us, please tell us your preferred user name and an account will be created for you. Please check this list to see if the user name you choose has not already been taken. We apologize for any inconvenience.
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 == "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 == "Personal attacks or 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('' + '' + '' + '' + '' + '' //Fancy stuff + '' + '' + '' + '
' + '' + '' + '
'Username: <input type="text" id="targetUser" name="targetUser" disabled=true value="' + target + '" /> Expiry: <input type="text" id="ebExpiry" name="ebExpiry" /> Reason: <input type="text" id="ebReason" name="ebReason" /> Block options: ' + (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') + ' ' + (!this.isIP(target) ? '<input type="checkbox" id="ebEmailBan" /> Block user from sending e-mail' : ) + ' <input type="checkbox" id="ebCreateAccount" /> Block user from creating accounts <input type="checkbox" id="ebAllowUsertalk" checked="true" /> Allow user to edit his or her talk page Template:† <input type="text" id="ebTemplate" name="ebTemplate" /> <input type="button" value="Block" id="blockButton" name="blockButton" onclick="easyblock.customBlock.submit()" /> + '
†Optional, but please include all wikimarkup and your signature if you specify it. For example:{{subst:uw-vblock|time=24 hours|subst=subst:}} ~~~~
' );}
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);
}