User:OwenX/monobook.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.
//<nowiki>
function addlilink(tabs, url, name){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
//////////////////////////////////////////
function addlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
}

// appends msg to the currently-editted page, sets the summary to summ,
// and marks or unmarks the Watch this page checkbox according to watch.
function edit_summary_watch(msg, summ, watch, line)
{
  var f = document.editform, t = f.wpTextbox1;
  if ((t.value.length > 0) && (line == 1))
    t.value += '\n';
  if (line == -1)
    t.value = msg + t.value;
  else
    t.value += msg;
  if (summ.charAt(0) == '+')
    f.wpSummary.value += summ.substr(1);
  else
    f.wpSummary.value = summ;
  f.wpWatchthis.checked = watch;
}

function add_talk_header()
{
    var from_page = "";
    var from_index = location.search.indexOf("&fakefrom=");
    if(from_index != -1)
      from_page = decodeURI(location.search.substring(from_index + 10));
    edit_summary_watch("== [[\:" + from_page + "]] ==", "\/\* " + from_page + "\*\/ ", true, 1);
}

function add_date_header()
{
   var months = new Array(12);
   months[0]  = "January";
   months[1]  = "February";
   months[2]  = "March";
   months[3]  = "April";
   months[4]  = "May";
   months[5]  = "June";
   months[6]  = "July";
   months[7]  = "August";
   months[8]  = "September";
   months[9]  = "October";
   months[10] = "November";
   months[11] = "December";

    var from_page = "";
    var from_index = location.search.indexOf("&fakefrom=");
    if(from_index != -1)
      from_page = decodeURI(location.search.substring(from_index + 10));

    var now = new Date();
    var month_year = months[now.getMonth()] + " " + now.getFullYear();
    edit_summary_watch("== " + month_year + " ==", "\/\* " + month_year + " - " + from_page + " \*\/ ", true, 1);
}

function vfddelete(){
    document.forms.deleteconfirm.wpReason.value = '[[Wikipedia:Articles for deletion/' + unescape(window.location.href.replace(/^.*\?title=([^&]+)&action=delete.*$/, '$1').replace(/_/g, ' ')).replace(/^(Talk|Wikipedia( talk)?):/, '') + ']]';
}

function csddelete(reason)
{
    reason_text = new Array("", "CSD:G1", "CSD:G2", "CSD:G3", "CSD:G4", "CSD:A1", "CSD:A3", "CSD:G11", "CSD:G10", "CSD:A7", "CSD:G12", "CSD:R1");
    document.forms.deleteconfirm.wpReason.value = reason_text[reason] + "\. " + document.forms.deleteconfirm.wpReason.value;
}

function testwarning(level, summ, sig, take_from)
{
    var from_page = "";
    var from_index = location.search.indexOf("&fakefrom=");
    if(from_index != -1)
      from_page = decodeURI(location.search.substring(from_index + 10));

    var user_warnings = new Array (
        "uw-create1", "uw-test1", "uw-vandalism2", "uw-vandalism3", "uw-vandalism4", "",
        "uw-vblock|time=24 hours|sig=yes", "blocked user|by=[[User:OwenX|OwenX]]", "usertalk-sprotect", "", "uw-delete1",
        "please_login", "uw-vandalism1", "uw-copyright");
    var msg = "{{" + (level == 8 ? "" : "subst:") + user_warnings [level] + (take_from == 1 ? "|" + from_page : "") +
        (level == 11 ? "|" + from_page.substring(5) : "") + "}}" + (sig==1 ? " ~\~\~\~\n" : "\n");
    edit_summary_watch (msg, summ, true, ((level != 8) ? 1 : -1));
}

function userpageban()
{
    edit_summary_watch("{{" + "subst:Indefblockeduser}}\n" , "Indefinitely blocked", true, -1);
}

// adds various tabs to call the above
function add_tabs()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Only add for pages with "Editing User talk:" somewhere in the title
  if ((document.title.indexOf("Editing User talk:") != -1) || (document.title.indexOf("Creating User talk:") != -1))
  {
      tabs.appendChild(addlilink('javascript:add_date_header()',"head"));
      tabs.appendChild(addlilink('javascript:testwarning(12,"+{{" + "uw-vandalism1}}",1,1)',"v1"));
      tabs.appendChild(addlilink('javascript:testwarning(2,"+{{" + "uw-vandalism2}}",1,1)',"v2"));
      tabs.appendChild(addlilink('javascript:testwarning(3,"+{{" + "uw-vandalism3}}",1,1)',"v3"));
      tabs.appendChild(addlilink('javascript:testwarning(4,"+{{" + "uw-vandalism4}}",1,1)',"v4"));
      tabs.appendChild(addlilink('javascript:testwarning(10,"+blanking",1,1)',"del"));
      tabs.appendChild(addlilink('javascript:testwarning(1,"+{{" + "uw-test1}}",1,1)',"test"));
      tabs.appendChild(addlilink('javascript:testwarning(0,"+{{" + "uw-create1}}",1,1)',"nn"));
      tabs.appendChild(addlilink('javascript:testwarning(13,"+{{" + "uw-copyright}}",1,1)',"cpv"));
      tabs.appendChild(addlilink('javascript:testwarning(11,"+Please log in.",1,0)',"login"));
      tabs.appendChild(addlilink('javascript:testwarning(6,"+Blocked for 24 hours.",0,0)',"24h"));
      tabs.appendChild(addlilink('javascript:testwarning(7,"Indefinitely blocked.",0,0)',"ban"));
      tabs.appendChild(addlilink('javascript:testwarning(8,"semi-protected",0,0)',"vut"));
   }
   else if (document.title.indexOf("Confirm delet") != -1)
   {
        tabs.appendChild(addlilink('javascript:vfddelete()', 'afd', ''));
        tabs.appendChild(addlilink('javascript:csddelete(1)', 'nons', ''));
        tabs.appendChild(addlilink('javascript:csddelete(2)', 'test', ''));
        tabs.appendChild(addlilink('javascript:csddelete(3)', 'vand', ''));
        tabs.appendChild(addlilink('javascript:csddelete(4)', 'recr', ''));
        tabs.appendChild(addlilink('javascript:csddelete(5)', 'cntxt', ''));
        tabs.appendChild(addlilink('javascript:csddelete(6)', 'void', ''));
        tabs.appendChild(addlilink('javascript:csddelete(7)', 'spam', ''));
        tabs.appendChild(addlilink('javascript:csddelete(8)', 'atck', ''));
        tabs.appendChild(addlilink('javascript:csddelete(9)', 'bio', ''));
        tabs.appendChild(addlilink('javascript:csddelete(10)', 'cpv', ''));
        tabs.appendChild(addlilink('javascript:csddelete(11)', 'redir', ''));
   }
  // Only add for pages with "Editing User:" somewhere in the title
  else if (document.title.indexOf("Editing User:") != -1)
  {
      tabs.appendChild(addlilink('javascript:userpageban()',"ban"));
  }

}

if (window.addEventListener)
  window.addEventListener("load", add_tabs, false);
else if (window.attachEvent)
  window.attachEvent("onload", add_tabs);

function hidevfd(){
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "none";
    document.getElementById('footer').style.display = 'none';
}

function showvfd(){
    var divs = document.getElementsByTagName("div");
    for(var x = 0; x < divs.length; ++x)
        if(divs[x].className.indexOf("vfd") != -1)
            divs[x].style.display = "";
    document.getElementById('footer').style.display = '';
}

function vfdlinks(){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(document.title.indexOf("Wikipedia:Articles for deletion") == 0){
        add_link2('javascript:hidevfd()', 'hide');
        add_link2('javascript:showvfd()', 'show');
    }
}

if (window.addEventListener) window.addEventListener("load",vfdlinks,false);
else if (window.attachEvent) window.attachEvent("onload",vfdlinks);

///////////////////////////////////////////////////////////////////
// AutoVFD by Korath
// This needs to change depending on skin used.
//////////////////////////////////////////////////////////////////
function add_link2(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var li = document.createElement('li');
  li.appendChild(na);

  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
  tabs.appendChild(li);
}

function strip_namespace(target)
{
  var colon = target.indexOf(':');
  if (colon != -1)
    {
      var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
      var ns = target.substring(0, colon);
      if (ns == '' || ns == 'Talk')
        return target.substring(colon + 1);
      else
        for (var i = 0; i < spaces.length; ++i)
          {
            if (ns == spaces[i]
                || ns == spaces[i] + '_talk')
              return target.substring(colon + 1);
          }
    }

  return target;
}
function copyvio()
{
  document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url=}}';
  document.editform.wpSummary.value = 'copyvio';

  var target = document.editform.action;
  target = target.substring(target.indexOf('title=') + 6,
                            target.lastIndexOf('&action=submit'));

  var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var date = new Date();
  date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate();

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia%3ACopyright_problems/' + date + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename,
              'cpvio',
              'status,location,directories,resizeable,scrollbars');
}

function autocopyvio()
{
  if (document.title.indexOf('Editing ') == 0)
    {
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
                
            }
        }

      if (action == 'copyviolist')
        {
          document.editform.wpTextbox1.value += '*' + '[[' + target + ']]' + ' from [' + ']. ~' + '~~' + '~\n';
          document.editform.wpSummary.value = 'Copyvio ' + '[[' + target + ']]';
        }
    }
}

if (window.addEventListener)
  window.addEventListener('load', autocopyvio, false);
else if (window.attachEvent)
  window.attachEvent('onload', autocopyvio);

function vfd()
{
  document.editform.wpTextbox1.value = '{' + '{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'AfD';
  document.editform.wpWatchthis.checked = true;

  var target = document.editform.action;
  target = target.substring(target.indexOf('title=') + 6,
                            target.lastIndexOf('&action=submit'));

  var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var date = new Date();
  date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate();

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia%3AArticles_for_deletion/' + pagename + '&action=edit&fakeaction=vfdsub&faketarget=' + target,
              'Vfd',
              'status,location,directories,resizable,scrollbars');
  window.open('/w/index.php?title=Wikipedia%3AArticles_for_deletion/Log/' + date + '&action=edit&fakeaction=vfdlist&faketarget=' + pagename,
              'VfdLog',
              'status,location,directories,resizable,scrollbars');
}

function closevfd(result)
{ 
	if(result == 1)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'KEEP\'\'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - keep", true, 0);
	}

	else if(result == 2)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'MERGE\'\'\' to \'\' \'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - merge", true, 0);
	}
	else if(result == 3)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'Speedy delete' \'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - speedy", true, 0);
	}
        else if (result == 4)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'DELETE\'\'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - delete", true, 0);
	}
        else if (result == 5)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'NO CONSENSUS\'\'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - no consensus", true, 0);
	}
        else if (result == 6)
	{
	        document.editform.wpTextbox1.value = "{{" + "subst:afd top}} \'\'\'REDIRECT\'\'\' to \'\'[\[\]\]\'\'. ~" + "~" + "~" + "~\n" + document.editform.wpTextbox1.value;
		edit_summary_watch("{{" + "subst:afd bottom}}", "close - redir", true, 0);
	}
}

function vfdvote(vote)
{
	if (vote == 1)
	        edit_summary_watch("*\'\'\'Delete\'\'\' ~"+"~"+"~"+"~", document.editform.wpSummary.value + "delete", true, 0);
	else if (vote == 2)
		edit_summary_watch("*\'\'\'Keep\'\'\' ~"+"~"+"~"+"~", document.editform.wpSummary.value + "keep", true, 0);
	else if (vote == 3)
		edit_summary_watch("*\'\'\'Merge\'\'\' ~"+"~"+"~"+"~", document.editform.wpSummary.value + "merge", true, 0);
	else if (vote == 4)
		edit_summary_watch("*\'\'\'Redirect\'\'\' ~"+"~"+"~"+"~", document.editform.wpSummary.value + "redirect", true, 0);

}

function vfdtalk(result)
{
     boiler1 = "=" + "=Articles for Deletion debate=" + "=\nThis article ";
     boiler2 = " an [" + "[Wikipedia:Articles for deletion|Articles for Deletion]" + "] debate. The discussion can be found [" + "[Wikipedia:Articles for deletion/{" + "{subst" + ":PAGENAME}" + "}|here]" + "]. ~" + "~" + "~" + "~";

     if(result == 1)
         edit_summary_watch(boiler1 + "survived" + boiler2, document.editform.wpSummary.value + "link to AfD", false, 1);
     else if (result == 2)
         edit_summary_watch(boiler1 + "was merged with and redirected to \'\' \'\' as a result of" + boiler2, document.editform.wpSummary.value + "link to AfD", true, 1);
     else if (result == 3)
         edit_summary_watch(boiler1 + "was redirected to \'\'[\[\]\]\'\' as a result of" + boiler2, document.editform.wpSummary.value + "link to AfD", true, 1);

}

// Remove AFD messagebox. Written by OwenX
function unvfd()
{
    var f = document.editform;
    if(f.wpTextbox1.value.indexOf("\<\!-- Please do not remove or change this AfD message") == 0)
    {
        var closing_notice = f.wpTextbox1.value.indexOf("\<\!-- End of AfD message");
        var end_notice = closing_notice + f.wpTextbox1.value.substring(closing_notice).indexOf("\n") + 1;
        for (; (end_notice < f.wpTextbox1.value.length) && ("\n\r ".indexOf(f.wpTextbox1.value.charAt(end_notice)) != -1); end_notice++)
            ;
        if ((end_notice > 1000) && (end_notice < 2000))
        {
            f.wpTextbox1.value = document.editform.wpTextbox1.value.substring(end_notice);
            f.wpSummary.value = "AfD closed.";
            f.wpWatchthis.checked = false;
        }
        else alert("Strange AfD notice encountered. Length: " + end_notice);
    }
    else
    {
        f.wpTextbox1.value = f.wpTextbox1.value.replace(/\{\{afd\}\}[\n\r\ ]*/,"");
        f.wpSummary.value = "AfD closed.";
        f.wpWatchthis.checked = false;
    }
}


function deletiontags()
{
    if (document.title.indexOf("Editing Wikipedia:Articles for deletion") != -1)
    {
        if (document.editform.wpTextbox1.value.indexOf("Please do not modify it") == -1)
        {
            add_link2('javascript:vfdvote(1)', 'v - d');
            add_link2('javascript:vfdvote(2)', 'v - k');
            add_link2('javascript:vfdvote(3)', 'v - m');
            add_link2('javascript:vfdvote(4)', 'v - r');
            add_link2('javascript:closevfd(4)', 'c - d');
            add_link2('javascript:closevfd(1)', 'c - k');
            add_link2('javascript:closevfd(2)', 'c - m');
            add_link2('javascript:closevfd(6)', 'c - r');
            add_link2('javascript:closevfd(3)', 'c - sd');
            add_link2('javascript:closevfd(5)', 'c - nc');
        }
    }
    else if (document.title.indexOf("Editing Wikipedia:Votes for deletion") == -1 && document.title.indexOf("Editing Wikipedia:Pages for deletion") == -1 && document.title.indexOf("Editing Wikipedia:Articles for deletion") == -1 && document.title.indexOf("Editing Talk:") == -1 && document.title.indexOf("Editing User talk:") == -1)
    {
        if((document.editform.wpTextbox1.value.indexOf("["+"[Template:Afd") == -1) &&
           (document.editform.wpTextbox1.value.indexOf("\{\{afd\}\}") == -1))
            add_link2('javascript:vfd()', 'afd');
        else
            add_link2('javascript:unvfd()', 'un-afd');
        add_link2('javascript:copyvio()', 'copyvio');
    }
    else if (document.title.indexOf("Editing Wikipedia:Votes for deletion") == -1 && document.title.indexOf("Editing Wikipedia:Pages for deletion") == -1 && document.title.indexOf("Editing Wikipedia:Articles for deletion") == -1 && document.title.indexOf("Editing Talk:") != -1 && document.title.indexOf("Editing User talk:") == -1)
    {
        add_link2('javascript:vfdtalk(1)','afd - k');
        add_link2('javascript:vfdtalk(2)','afd - m');
        add_link2('javascript:vfdtalk(3)','afd - r');
    }
}

function autovfd()
{
  if (document.title.indexOf('Editing ') == 0)
    {
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
            }
        }

      if (action == 'vfdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'subst:afd3|pg=' + target + '}}\n';
          document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]';
          document.editform.wpWatchthis.checked = false;
        }
      else if (action == 'vfdsub')
        {
          if (document.editform.wpTextbox1.value.length > 0)
            {
              target = document.editform.action;
              target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' ');
              window.alert("There's an old vfd at the default location already.\n\n" +
                           'Please either move it out of the way (and update existing links to it), or file the AfD by hand in another location (such as [[' + target + ' (2)]]).');
            }
          else
          {
            document.editform.wpTextbox1.value += "{{" + "subst:afd2|pg=" + target + "|text=\'\'\'Delete\'\'\'}} ~" + "~" + "~" + "~";
            document.editform.wpSummary.value = 'Nominate';
            document.editform.wpWatchthis.checked = true;
          }
        }
      else
           deletiontags();
    }
}

if (window.addEventListener)
  window.addEventListener('load', autovfd, false);
else if (window.attachEvent)
  window.attachEvent('onload', autovfd);

// Returns <li><a href="url">name</a></li>
function addlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

  var txt = document.createTextNode(name);
  na.appendChild(txt);

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
}

//function do_onload()
//{
//  if (document.title.indexOf('User:') == 0
//      || document.title.indexOf('User talk:') == 0)
//    add_block_tab();
//}

// Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&faketarget=username" is present.
function do_blockip_stuff()
{
  // focus on Reason field
  document.getElementsByName('wpBlockReason')[0].focus();

  // Look for a &faketarget= for the username/ip
  var l = location.search.substring(1).split('&');
  var target = '';
  for (var i = 0; i < l.length; ++i)
    {
      var n = l[i].indexOf('=');
      if (l[i].substring(0, n) == 'faketarget')
	{
	  target = l[i].substring(n + 1);
	  break;
	}
    }

  if (target == '')
    return;

  // put account name in "IP Address/username" field
  var addr = document.getElementsByName('wpBlockAddress')[0];
  addr.value = unescape(target);

  // add "blocklog" tab
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target, 'blocklog'));
}

// Opens the block log in the current window, and Special:Blockip in a popup.
// Width, height, top, and left are chosen for a 1600x1200 display. (fixed for 1280x1024)
// function blockpage_and_log(target)
// {
//   window.open('/w/index.php?title=Special%3ABlockip&faketarget=' + target, 'Block',
//       'resizable,scrollbars,width=1000,height=400,top=500,left=150');
//   document.location.href = 'http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target;
// }

// Adds "block" and "blocklog" tabs to User: and User talk: pages.
function add_block_tab()
{
  /* debug alert("reached add_block_tab!"); */

  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // use the "edit this page" tab to get already-tidied url
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  // cut everything up to "title=" from the start and everything past "&action=edit" from the end
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
  editlk = editlk.substring(editlk.indexOf(':') + 1);
  var slloc = editlk.indexOf('/');
  if (slloc > 0)
    editlk = editlk.substring(0, slloc);

  // add "block" tab
  //tabs.appendChild(addlilink('/w/index.php?title=Special%3ABlockip&faketarget=' + editlk, 'block'));

  // To open the block page and block log simultaneously, replace the above line with:
  // tabs.appendChild(addlilink('javascript:blockpage_and_log("' + editlk + '")', 'Block'));
  // and uncomment the blockpage_and_log() function above.

  // add "blocklog" tab
  tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'blocklog'));

  // add "unblock" tab
  tabs.appendChild(addlilink('/w/index.php?title=Special%3AIpblocklist&action=unblock&ip=' + editlk, 'unblock'));

  // add "rights" tab
  // tabs.appendChild(addlilink('/w/wiki.phtml?title=Special%3AListusers&limit=1&username=' + editlk.replace(/_/g,'\+'),
  //   'rights'));
     tabs.appendChild(addlilink('/w/index.php?title=Special%3AUserRights&user=' + editlk.replace(/_/g,'\+'),
         'rights'));

  // add "kate" tab
  // tabs.appendChild(addlilink('//toolserver.org/~river/cgi-bin/count_edits?user=' + editlk + '&dbname=enwiki_p', 'kate'));

  // add "DaB" tab
  // tabs.appendChild(addlilink('//toolserver.org/editcount/result?username=' + editlk +
  //    '&projectname=enwiki&showgraphs=2d', 'DaB'));

  // add "Soxred93" tab
  // tabs.appendChild(addlilink('//toolserver.org/~soxred93/ec/' + editlk, 'Sox'));

  // add "Tparis" tab
  tabs.appendChild(addlilink('//toolserver.org/~tparis/pcount/index.php?name=' + editlk + 
      '&lang=en&wiki=wikipedia', 'Count'));

  // add "RfA" tab
  tabs.appendChild(addlilink('/wiki/Wikipedia:Requests_for_adminship/' + editlk, 'RfA'));

  // add "RfB" tab
  tabs.appendChild(addlilink('/wiki/Wikipedia:Requests_for_bureaucratship/' + editlk, 'RfB'));

  // add "Interiot" tab
  //tabs.appendChild(addlilink('http://toolserver.org/~interiot/cgi-bin/Tool1/wannabe_kate?username=' + editlk +
  //   '&site=en.wikipedia.org', 'Interiot'));

  // add "Essjay" tab
  // tabs.appendChild(addlilink('http://toolserver.org/~essjay/edit_count/Count.php?username=' + editlk, 'Essjay'));
}

///////////////////////////////////////////
// View vandal contribs and issue warnings 
// triggers on diff pages
// Written by OwenX
///////////////////////////////////////////
function warn_vandal(vandalname, page)
{
  window.open('/w/index.php?title=Special:Contributions&target=' + vandalname,
              'vc_' + escape(vandalname.replace(/\W/g, '_')), // needs unique name to allow multiple windows
              'status,location,directories,resizable,scrollbars,top=180,height=520,left=200,width=900');
  document.location.href = 'http://en.wikipedia.org/w/index.php?title=User_talk:' + vandalname + '&action=edit&fakefrom=' + page;
}

//////////////////////////////////////
// Mass checkbox manipulation
// for version undelete and watchlist
// by OwenX
//////////////////////////////////////
function any_boxes()
{
    for (i=0; i<document.forms.length; i++)
        for (j=0; j<document.forms[i].elements.length; j++)
            if (document.forms[i].elements[j].type == 'checkbox')
                return true;
    return false;
}

function check_all_boxes(act)
{
    var in_range = false;
    for (i=0; i<document.forms.length; i++)
    {
        for (j=0; j<document.forms[i].elements.length; j++)
        {
            f= document.forms[i].elements[j];
            if (f.type == 'checkbox')
            {
                if (act == 1)
                    f.checked = true;
                else if (act == 0)
                    f.checked = false;
                else if (act == -1)
                    f.checked = !f.checked;
                else if (act == 2)
                {
                    if (in_range)
                        if (f.checked)
                        {
                            in_range = false;
                            break;
                        }
                        else
                            f.checked = true;
                    else if (f.checked)
                        in_range = true;
                }
            }
        }
    }
}

function do_checkboxing()
{
    if (any_boxes())
    {
        var c1 = document.getElementById('column-one');
        var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

        tabs.appendChild(addlilink('javascript:check_all_boxes(1)', 'Check all'));
        tabs.appendChild(addlilink('javascript:check_all_boxes(0)', 'Uncheck all'));
        tabs.appendChild(addlilink('javascript:check_all_boxes(-1)', 'Invert all'));
        tabs.appendChild(addlilink('javascript:check_all_boxes(2)', 'Fill range'));
    }
}

function do_warn_stuff()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  var rcol = document.getElementById('mw-diff-ntitle2');
  if (rcol != null)
  {
    var rmsg = rcol.innerHTML;
    var vandalname = rmsg.substring(rmsg.indexOf('\">')+7, rmsg.indexOf('</'));
    var page = document.title.substring (0, document.title.indexOf(": Difference between revisions"));
    tabs.appendChild(addlilink('javascript:warn_vandal("' + vandalname + '","' + page + '")', 'Warn'));
  }
}

function do_onload()
{
  /* debug */ /* alert(document.title); */
  if (document.title.indexOf('User:') == 0
      || document.title.indexOf('User talk:') == 0
      || document.title.indexOf('Editing User talk:') == 0
      || document.title.indexOf('Creating User talk:') == 0)
    add_block_tab();
  else if (document.title.indexOf('Block user') == 0) // could stand to be more robust
    do_blockip_stuff();
  else if (document.title.indexOf('View and restore deleted pages') == 0 ||
           document.title.indexOf('Edit watchlist') == 0)
    do_checkboxing();

  var diffbody = document.getElementById('firstHeading');
  if (diffbody != null && diffbody.innerHTML.indexOf('Difference between revisions') > -1)
    do_warn_stuff();
}

if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);

//	Released into the public domain by [[User:Func]]
function NUPatrol()
{
	if ( window.location.href.indexOf( 'Special:Log/newusers'        ) < 0 &&
	     window.location.href.indexOf( '&type=newusers' ) < 0  ) return;

	var items, item, i, links, user, name, talk, contribs, insertLoc, link;

	items = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' );

	function NewLink( txt, url, plainlinks, linkColor )
	{	var a = document.createElement( 'a' );
			a.appendChild( document.createTextNode( txt ) );
			a.href = url;
		if ( plainlinks ) a.className = 'plainlinks';
		if ( linkColor )
		{	if ( typeof linkColor == "string" )
					a.style.color = linkColor;
			else	a.style.color = '#FF0000'; // old default behavior
		}
		return a;
	}

	for ( i = 0; i < items.length; i++ )
	{
		item = items[ i ];
		
		links = item.getElementsByTagName( 'a' );

			user = links[ 0 ]; name = user.firstChild.nodeValue;
			talk = links[ 2 ]; talk.firstChild.nodeValue = 'talk'; // lowercase 'Talk' for consistency
		contribs = links[ 3 ];

		insertLoc = user.nextSibling; // ' newusers '

		item.insertBefore( document.createTextNode( ' ( ' ), insertLoc );

		item.insertBefore( talk, insertLoc );
		item.insertBefore( document.createTextNode( ', ' ), insertLoc );

		item.insertBefore( contribs, insertLoc );
		item.insertBefore( document.createTextNode( ', ' ), insertLoc );

		item.insertBefore( NewLink( 'actions', '/w/index.php?title=Special%3ALog&user=' + name, true, '#000088' ), insertLoc );
		item.insertBefore( document.createTextNode( ', ' ), insertLoc );

		item.insertBefore( NewLink( 'blocks', '/w/index.php?title=Special%3ALog&type=block&page=User%3A' + name, true, '#008800' ), insertLoc );
		item.insertBefore( document.createTextNode( ', ' ), insertLoc );

		item.insertBefore( NewLink( 'is blocked?', '/wiki/Special:Ipblocklist?action=search&ip=' + name, true, '#888800' ), insertLoc );
		item.insertBefore( document.createTextNode( ', ' ), insertLoc );

		item.insertBefore( NewLink( 'do block!', '/w/index.php?title=Special:Blockip&ip=' + name, true, '#880000' ), insertLoc );

		item.insertBefore( document.createTextNode( ' )' ), insertLoc );

		item.removeChild( insertLoc.nextSibling ); // should remove the span
		item.removeChild( insertLoc ); // should remove ' newusers ' text
	}
}
if ( window.addEventListener ) window.addEventListener( 'load', NUPatrol, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', NUPatrol );

/* importScript('User:Mr.Z-man/closeAFD.js'); no longer supported */

//</nowiki>