User:Kanonkas/block options.js

Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// ======== QuickBlocks =======
function QuickBlock (expiry,reason,ao,autob) {
  blockForm = document.getElementById('blockip');
  inputs = blockForm.getElementsByTagName('input');
  for (i=0; i<inputs.length; i++) {
    if (inputs[i].name == 'wpBlockOther') {
      inputs[i].value = expiry;
      continue;
    }
    if (inputs[i].name == 'wpBlockReason') {
      inputs[i].value = reason;
      continue;
    }
    if (inputs[i].name == 'wpAnonOnly') {
      if (ao==1) {
        inputs[i].checked = 'checked';
      }
      continue;
    }
    if (inputs[i].name == 'wpEnableAutoblock') {
      if (autob==0) {
        inputs[i].checked=false;
      }
      continue;
    }
  }
  blockForm.submit();
}
 
addOnloadHook(function(){
  if (document.title.indexOf("Block user") == -1) return;
addTab('javascript:('+QuickBlock+')("indefinite","Please read our [[WP:U|username policy]] and choose another name",0,0)','Username','p-block-user');
  addTab('javascript:('+QuickBlock+')("indefinite","vandal account",0,1)','Vandal acc','p-block-vandalism');
  addTab('javascript:('+QuickBlock+')("indefinite","Similar to existing user or recent meme: please [[Special:Emailuser/Luna Santin|Email me]] if you are a legitimate editor.",0,1)','sockpuppet','p-block-sock');
  addTab('javascript:('+QuickBlock+')("31 hours","Blocked for 31 hours due to recent vandalism. If this is a shared address, please register an account to avoid collateral damage.",1,1)','31 hours','p-block-31h');
  addTab('javascript:('+QuickBlock+')("1 week","Blocked for one week due to repeat vandalism. If this is a shared address, please register an account to avoid collateral damage.",1,1)','Week','p-block-school');
  addTab('javascript:('+QuickBlock+')("1 month","Blocked for one month due to chronic vandalism. If this is a shared address, please register an account to avoid collateral damage.",1,1)','Month','31-days');
  addTab('javascript:('+QuickBlock+')("31 hours","Blocked for 31 hours due to recent trolling. If this is a shared address, please register an account to avoid collateral damage.",1,1)','Troll-31','p-block-troll-31');
  addTab('javascript:('+QuickBlock+')("indefinite","Trolling",0,1)','Troll-indef','p-block-troll-indef');
});
 
function substNRD() {
  if (document.editform) {
    document.editform.wpTextbox1.value = "\n{{" + "di-disputed fair use rationale|date=8 July 2008|concern=Image fails [[WP:NFCC#8]]}}\n"+document.editform.wpTextbox1.value;
    document.editform.wpSummary.value = "{{subst:[[Template:di-disputed fair use rationale|di-disputed fair use rationale]]}}";
    document.editform.submit();
  } else
    document.location = mw.config.get('wgServer') + mw.config.get('wgScript') + "?title=" + wgPageName + "&action=edit&substNRD=1";
}
function addSubstNRD(){
  if (wgCanonicalNamespace == "Image")
    mw.util.addPortletLink("p-cactions", "javascript:substNRD()", "{{" + "dfu}}", "");
  if (document.location.href.indexOf("substNRD=1") > 0)
    substNRD();
}
addOnloadHook(addSubstNRD);