Jump to content

User:49TL/monobook.js/old

From Wikipedia, the free encyclopedia

importScript('User:Xy7/autowarn.js'); importScript('User:Xy7/checkedits.js');

/*

 */

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Xy7's monobook
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helper tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Voice of All
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Addtabs/monobook.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Warning tools (stolen from Lorian and edited a bit)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getElementsByClass(searchClass,node,tag) {
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

var _GET = new Array();
var _uri = location.href;

var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");

var _temp_get_arr_1 = new Array();

for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
  _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
  _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}

delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;

$(function (){
  if (location.href.match(/diff=/)) {
    // Get username of submitter
    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
    document.getElementById('contentSub').innerHTML = '(Warn: <a>Test 1</a>)';
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (1)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/1}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (1)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/1d}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (2)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/2}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=4/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (2)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/2d}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=5/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (3)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/3}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=6/)) {
    document.getElementById('wpSummary').value = 'vandalism warning (4)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/w/v/4}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=7/)) {
    document.getElementById('wpSummary').value = 'blocked (vandalism)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/uw-block1}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=8/)) {
    document.getElementById('wpSummary').value = 'blocked (vandalism)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/uw-block3}}';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=9/)) {
    document.getElementById('wpSummary').value = 'blocked (username)';
    document.getElementById('wpTextbox1').value += '\n{{sub'+'st:User:Xy7/block/i/u}}';
    document.getElementById('editform').submit();
  }
});

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Instaview
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Pilaf/instaview.js&action=raw&ctype=text/javascript');

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Formatter
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function format() {
    var txt = document.editform.wpTextbox1;
    txt.value = catFixer(txt.value);
    txt.value = entities(txt.value);
    txt.value = fixheadings(txt.value);
    txt.value = fixsyntax(txt.value);
    txt.value = linkfixer(txt.value, false);
    //txt.value = imagefixer(txt.value);
    txt.value = whitespace(txt.value);
    txt.value = linksimplifyer(txt.value);
    txt.value = trim(txt.value);
}

function whitespace(str){
    str = str.replace(/\t/g, " ");

    str = str.replace(/^ ? ? \n/gm, "\n");
    str = str.replace(/(\n\n)\n+/g, "$1");
    str = str.replace(/== ? ?\n\n==/g, "==\n==");
    str = str.replace(/\n\n(\* ?\[?http)/g, "\n$1");

    str = str.replace(/^ ? ? \n/gm, "\n");
    str = str.replace(/\n\n\*/g, "\n*");
    str = str.replace(/[ \t][ \t]+/g, " ");
    str = str.replace(/([=\n]\n)\n+/g, "$1");
    str = str.replace(/ \n/g, "\n");

    //* bullet points
    str = str.replace(/^([\*#]+) /gm, "$1");
    str = str.replace(/^([\*#]+)/gm, "$1 ");

    //==Headings==
    str = str.replace(/^(={1,4}) ?(.*?) ?(={1,4})$/gm, "$1$2$3");

    //dash — spacing
    str = str.replace(/ ?(–|–|–|–|–) ?/g, "$1");
    str = str.replace(/ ?(—|—|—|—|—) ?/g, "$1");
    str = str.replace(/([^1-9])(—|—|—|—|—|–|–|–|–|–)([^1-9])/g, "$1 $2 $3");

    return trim(str);
}

function entities(str){
    //str = str.replace(//g, "");
    str = str.replace(/–|–|–/g, "–");
    str = str.replace(/—|—|—/g, "—");
   // str = str.replace(/(cm| m|km|mi)<sup>2</sup>/g, "$1²");
    str = str.replace(/²/g, "²");
    str = str.replace(/°/g, "°");

    return trim(str);
}

//Fix ==See also== and similar section common errors.
function fixheadings(str)
{
  if( !str.match(/= ?See also ?=/) )
    str = str.replace(/(== ?)(see also:?|related topics:?|related articles:?|internal links:?|also see:?)( ?==)/gi, "$1See also$3");

  str = str.replace(/(== ?)(external links?:?|outside links?|web ?links?:?|exterior links?:?)( ?==)/gi, "$1External links$3");
  str = str.replace(/(== ?)(references?:?)( ?==)/gi, "$1References$3");
  str = str.replace(/(== ?)(sources?:?)( ?==)/gi, "$1Sources$3");
  str = str.replace(/(== ?)(further readings?:?)( ?==)/gi, "$1Further reading$3");

  return str;
}

function catFixer(str){
    str = str.replace(/\[\[ ?[Cc]ategory ?: ?/g, "[[Category:");

    return trim(str);
}

//fixes many common syntax problems
function fixsyntax(str)
{
  //replace html with wiki syntax
  if( !str.match(/'<\/?[ib]>|<\/?[ib]>'/gi) )
  {
    str = str.replace(/<i>(.*?)<\/i>/gi, "''$1''");
    str = str.replace(/<b>(.*?)<\/b>/gi, "'''$1'''");
  }
  str = str.replace(/<br\/>/gi, "<br />");
  str = str.replace(/<br>/gi, "<br />");
                      
  return trim(str);
}

//formats links in standard fashion
function linkfixer(str, checkImages)
{ 
  str = str.replace(/\]\[/g, "] [");
  var m = str.match(/\[?\[[^\]]*?\]\]?/g);
  if (m)
  {
    for (var i = 0; i < m.length; i++)
    {
      var x = m[i].toString();
      var y = x;

      //internal links only
      if ( !y.match(/^\[?\[http:\/\//i) && !y.match(/^\[?\[image:/i) )
      {
        if (y.indexOf(":") == -1 && y.substr(0,3) != "[[_" && y.indexOf("|_") == -1)
        {
          if (y.indexOf("|") == -1)
            y = y.replace(/_/g, " ");
          else
            y = y.replace( y.substr(0, y.indexOf("|")), y.substr(0, y.indexOf("|")).replace(/_/g, " "));
        }  
      
        y = y.replace(/ ?\| ?/, "|").replace("|]]", "| ]]");
        
      }

      str = str.replace(x, y);
    }
  }

  //repair bad internal links
  str = str.replace(/\[\[ ?([^\]]*?) ?\]\]/g, "[[$1]]");
  str = str.replace(/\[\[([^\]]*?)( |_)#([^\]]*?)\]\]/g, "[[$1#$3]]");

  //repair bad external links
  str = str.replace(/\[?\[http:\/\/([^\]]*?)\]\]?/gi, "[http://$1]");
  str = str.replace(/\[http:\/\/([^\]]*?)\|([^\]]*?)\]/gi, "[http://$1 $2]");

  return trim(str);
}

//fixes images
function imagefixer(str)
{

  //remove external images
  str = str.replace(/\[?\[image:http:\/\/([^\]]*?)\]\]?/gi, "[http://$1]");

  //fix links within internal images
  var m = str.match(/\[?\[image:[^\[\]]*?(\[?\[[^\]]*?\]*?[^\[\]]*?)*?\]+/gi);
  if (m)
  {
    for (var i = 0; i < m.length; i++)
    {
      var x = m[i].toString();
      var y = x;

      y = y.replace(/^\[\[i/i, "I").replace(/\]\]$/, "");
      y = y.replace(/(\[[^\]]*?)$/, "$1]");
      y = linkfixer(y, true);
      y = "[[" + y + "]]";

      str = str.replace(x, y);
    }
  }

  return trim(str);
}

//simplifies some links e.g. [[Dog|dog]] to [[dog]] and [[Dog|dogs]] to [[dog]]s
function linksimplifyer(str){
  var m = str.match(/\[\[([^[]*?)\|([^[]*?)\]\]/g);
  if (m)
  {
    for (var i = 0; i < m.length; i++)
    {
      var n_arr = m[i].toString().match(/\[\[([^[]*?)\|([^[]*?)\]\]/);
      var n = n_arr[0];
      var a = n_arr[1];
      var b = n_arr[2];

      if (b.indexOf(a) == 0 || b.indexOf(TurnFirstToLower(a)) == 0)
      {
        var k = n.replace(/\[\[([^\]\|]*?)\|(\1)([\w]*?)\]\]/i, "[[$2]]$3");
        str = str.replace(n, k);
      }
    }
  }

  str = str.replace(/\[\[([^\]\|]+)\|([^\]\|]+)\]\]([A-Za-z\'][A-Za-z]*)([\.\,\;\:\"\!\?\s\n])/g, "[[$1|$2$3]]$4");

  return str;
}

//trim start and end, trim spaces from the end of lines
function trim(str) {
   str = str.replace(/ $/gm, "");
   return str.replace(/^\s*|\s*$/g, "");
}

//turns first character to lowercase
function TurnFirstToLower(input) {
  if (input != "")
  {
    var input = trim(input);
    var temp = input.substr(0, 1);
    return temp.toLowerCase() + input.substr(1, input.length);
  }
  else
    return "";
}

//entities that should never be unicoded
function noUnicodify(str) {
  str = str.replace(" & ", " & ");
  str = str.replace("&", "&").replace("<", "&lt;").replace(">", "&gt;").replace(""", "&quot;").replace("'", "&apos;");
  str = str.replace("−", "−").replace("×", "×");

  str = str.replace(" ", " ").replace(" ", " ").replace("­", "­");
  str = str.replace("′", "′");
  str = str.replace(/&(#0?9[13];)/, "&$1");
  str = str.replace(/&(#0?12[345];)/, "&$1");

  return str;
}

$(function () {
  if(document.forms.editform) {
    mw.util.addPortletLink('p-cactions', 'javascript:format()', 'format', 'ca-format', 'Format article', '', document.getElementById('ca-edit'));
  }
});

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Twinkle
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// importScript('User:AzaToth/morebits.js');
// importScript('User:AzaToth/twinklefluff.js');

// TwinkleConfig = {
//         revertMaxRevisions              :       50,
//         userTalkPageMode                :       'tab',
//         showSharedIPNotice              :       false,
//         openTalkPage                    :       [ 'norm', 'vand' ],
//         openTalkPageOnAutoRevert        :       false,
//         openAOLAnonTalkPage             :       false,
//         summaryAd                       :       " ",
//         deletionSummaryAd               :       " ",
//         protectionSummaryAd             :       " ",
//         watchSpeedyPages                :       [ 'g3', 'g5', 'g10', 'g11', 'g12' ],
//         watchProdPages                  :       false,
//         openUserTalkPageOnSpeedyDelete  :       [ 'g1', 'g2', 'g10', 'g11', 'g12', 'a1', 'a7', 'i3', 'i4', 'i5', 'i6', 'i7', 'u3', 't1' ],
//         watchRevertedPages              :       [ ],
//         markRevertedPagesAsMinor        :       [ ],
//         deleteTalkPageOnDelete          :       false,
//         markWarningsAsMinor             :       false,
//         markAIVReportAsMinor            :       false,
//         markSpeedyPagesAsMinor          :       false,
//         markProdPagesAsMinor            :       false,
//         confirmUsernameToAIV            :       true,
//         toolboxButtons                  :       [ ]
// };

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Find and replace
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

hookEvent("load", function()
{
	var lang, textBox = document.getElementById("wpTextbox1");
	if(!textBox) return;
	try{  lang = Gerbrant.edit.regexReplace.lang;  }catch(nopresets){}
	if(!lang) lang = wgUserLanguage;
	switch(lang)
	{

// Localized strings:

case "nl": str =
{
	finished: "Voltooid; $1 items werden vervangen.",
	finished2: "Voltooid; $1 van $2 items werden vervangen.",
	notFound: "De gevraagde tekst is niet gevonden.",
	replace: "Vervangen...",
	replaceSel: "Vervang selectie",
	errorNoCheckBox: "Kan het corresponderende keuzevakje niet vinden.",
	useRepFun: "< functie >"
};
break;

default: str =
{
	finished: "Finished; $1 items were replaced.",
	finished2: "Finished; $1 out of $2 items were replaced.",
	notFound: "Requested text was not found.",
	replace: "Replace...",
	replaceSel: "Replace selection",
	errorNoCheckBox: "Cannot find the corresponding checkbox.",
	useRepFun: "< function >"
};

// Don't localize anything beyond this point.

	}

	var regex, text, minFrag = 30, minDel = 10, repFun;

	var results = document.createElement("DIV");
	var tbRegex = document.createElement("INPUT");
	//tbRegex.value = "[A-Z]{2,}";

	var hl = document.createElement("INPUT");
	hl.type = "checkbox";

	var rep = document.createElement("DIV");
	rep.style.display = "none";

	function findMatches()
	{
		var m = [], r = [], i = 0;
		regex = new RegExp(tbRegex.value, hl.checked ? "g" : "ig");
		text = textBox.value;

		var t = text.replace(regex, function(a)
		{
			m.push(a);
			return "\u0001";
		}).split("\u0001");

		if(m.length == 0)
		{
			results.innerHTML = str.notFound;
			return;
		}

		if(t[0].length > minFrag + minDel)
		{
			r.push(" \u2026 ");
			r.push(t[0].slice(-minFrag));
		}
		else
			r.push(t[0]);
		while(true)
		{
			r.push('\u0001b>\u0001input type="checkbox" checked id="Gerbrant-errCB');
			r.push(i);
			r.push('">');
			r.push(m[i]);
			r.push('\u0001/b>');
			if(++i >= m.length) break;
			if(t[i].length > 2 * minFrag + minDel)
			{
				r.push(t[i].slice(0, minFrag));
				r.push(" \u2026 ");
				r.push(t[i].slice(-minFrag));
			}
			else
				r.push(t[i]);
		}
		if(t[i].length > minFrag + minDel)
		{
			r.push(t[i].slice(0, minFrag));
			r.push(" \u2026 ");
		}
		else
			r.push(t[i]);

		rep.style.display = "";
		results.innerHTML = r.join("").replace(
			/&/g, "&").replace(
			/</g, "<").replace(
			/\u0001/g, "<").replace(
			/\n[ \t]/g, "\n ").replace(
			/[ \t](?=[ \t])/g, " ").replace(
			/\n/g, "<br>");
	}

	var ok = document.createElement("INPUT");
	ok.type = "button";
	ok.value = str.replace;
	ok.onclick = findMatches;

	var div = document.createElement("DIV");
	div.appendChild(tbRegex);
	div.appendChild(hl);
	div.appendChild(ok);

	var tbReplace = document.createElement("INPUT");
	//tbReplace.value = "function(a){return a.slice(0,1) + a.slice(1).toLowerCase();}";
	
	var chkJS = document.createElement("INPUT");
	chkJS.type = "checkbox";

	function doReplace()
	{
		var rjs = chkJS.checked, i = 0, j = 0, r, nt;
		var ohno = false;
		r = tbReplace.value;
		if(rjs)
			if(r == str.useRepFun) r = repFun;
			else eval("r=" + r);
		nt = text.replace(regex, function(a)
		{
			var c = document.getElementById("Gerbrant-errCB" + i++);
			if(c)
				if(c.checked)
				{
					j++;
					if(rjs)
						try
						{
							return r.apply(RegExp, arguments);
						}
						catch(e)
						{
							alert(e.message);
							return a;
						}
					else
						return r;
				}
				else
					return a;
			else
				ohno = true;
		});
		if(ohno)
		{
			alert(str.errorNoCheckBox);
			return;
		}
		if(j < i) results.innerHTML = str.finished2.replace("$1", j).replace("$2", i);
		else results.innerHTML = str.finished.replace("$1", j);
		rep.style.display = "none";
		textBox.value = nt;
	}

	var finish = document.createElement("INPUT");
	finish.type = "button";
	finish.value = str.replaceSel;
	finish.onclick = doReplace;

	rep.appendChild(tbReplace);
	rep.appendChild(chkJS);
	rep.appendChild(finish);

	textBox.parentNode.insertBefore(div, textBox);
	textBox.parentNode.insertBefore(rep, textBox);
	textBox.parentNode.insertBefore(results, textBox);

	function onResize()
	{
		finish.style.height = ok.style.height = tbRegex.offsetHeight;
		tbRegex.style.width = textBox.offsetWidth - ok.offsetWidth - hl.offsetWidth;
		tbReplace.style.width = textBox.offsetWidth - finish.offsetWidth - chkJS.offsetWidth;
	}
	onResize();
	hookEvent("resize", onResize);

	if(typeof module == "function")
		module("Gerbrant.edit.regexReplace", {replace: function(what, ulcase, repl, isjs)
		{
			tbRegex.value = what;
			hl.checked = ulcase;
			if(isjs == undefined && typeof repl == "function")
			{
				repFun = repl;
				tbReplace.value = str.useRepFun;
				chkJS.checked = true;
			}
			else
			{
				tbReplace.value = repl;
				chkJS.checked = isjs;
			}
			findMatches();
		}});
});

if(typeof loadModule == "function")
{
	new function()
	{
		var presets;
		try{  presets = Gerbrant.edit.regexReplace.presets;  }catch(nopresets){}
		if(presets)
			loadModule("Gerbrant.gui.lilink", function(l)
			{
				hookEvent("load", function()
				{
					var i, p, e = function(s)
					{
						return s.toString().replace(/["\\]/g, function(a)
						{
							return "\\" + a;
						});
					};
					if(!document.getElementById("wpTextbox1")) return;
					for(i in presets)
					{
						p = presets[i];
						l.addToolboxLink('javascript:Gerbrant.edit.regexReplace.replace("' +
							e(p.regex) + '",' + !!p.caseSens + ',"' +
							e(p.replace) + '",' +
							(typeof(p.replace) == "function") + ');', i);
					}
				});
			});
	};
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Six tabs
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//if (wgNamespaceNumber >= 0)
//addOnloadHook(function(){
// var pCactions = document.getElementById('p-cactions');
// if (!pCactions) return;
// var caMain = pCactions.getElementsByTagName('li')[0];
// var caTalk = document.getElementById('ca-talk');
// var caEdit = document.getElementById('ca-edit');
// if (!caEdit) caEdit = document.getElementById('ca-viewsource');
// var caHistory = document.getElementById('ca-history');
// if (!caMain || !caTalk || !caEdit || !caHistory) return;
// var el_move, el_create, id2;
// if (wgNamespaceNumber % 2) { //talk space
//   el_move = caTalk; el_create = caMain; id2 = '';
// } else {
//   el_move = caMain; el_create = caTalk; id2 = 'discussion';
// }
// caEdit.firstChild.innerHTML = 'edit';
// caHistory.firstChild.innerHTML = 'hist';
// el_move.parentNode.insertBefore(caHistory, el_move.nextSibling);
// el_move.parentNode.insertBefore(caEdit, el_move.nextSibling);
// var href = el_create.firstChild.getAttribute('href', 2);
// if (el_create.className.indexOf('new') < 0){
//   mw.util.addPortletLink('p-cactions', href + '?action=history', 'hist',
//     'ca-history-'+id2, id2+' history', '', el_create.nextSibling);
//   mw.util.addPortletLink('p-cactions', href + '?action=edit', 'edit',
//     'ca-edit-'+id2, 'Edit '+id2, '', el_create.nextSibling);
// } 
//  caMain.style.marginRight = '0.3em'; 
//  caTalk.style.marginRight = '0.3em'; 
//  caTalk.style.marginLeft  = '1.6em'; 
//})

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CSD deletion
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
if (document.title.indexOf("Confirm deletion") != -1 || document.title.indexOf("Confirm delete") != -1) {
     var csdDeleteForm = {
				FillSelect:function(sel, arr){
					if(arr && arr.length>0){
						if(arr.length>1){
							var FirstOpt = new Option("CSD Reasons", "");
							// catches stupid IE error
							if(FirstOpt.innerHTML != "CSD Reasons"){
								FirstOpt.innerHTML = "CSD Reasons";
							}
							sel.appendChild(FirstOpt);
							sel.options[0].style.color = "gray"
						}
						sel.disabled = false;
						for(var i=0;i<arr.length;i++){
							var opt = new Option(arr[i].display, arr[i].value);
							// catches stupid IE error
							if(opt.innerHTML != arr[i].display){
								opt.innerHTML = arr[i].display;
							}
							sel.appendChild(opt);
						}
					}else{
						sel.options[0] = new Option("No Options Available", "");
						// catches stupid IE error
						if(sel.options[0].innerHTML != "No Options Available"){
							sel.options[0].innerHTML = "No Options Available";
						}
						sel.disabled = true;
						return false;
					}
					return true;
				},
                                ValueArray:[
                                        {"value":"[[WP:CSD#G1|CSD G1]]: Nonsense","display":"G1 - Nonsense"},
                                        {"value":"[[WP:CSD#G2|CSD G2]]: Test page","display":"G2 - Test page"},
                                        {"value":"[[WP:CSD#G3|CSD G3]]: Vandalism","display":"G3 - Vandalism"},
                                        {"value":"[[WP:CSD#G4|CSD G4]]: Recreation of deleted material","display":"G4 - Recreation of deleted material"},
                                        {"value":"[[WP:CSD#G6|CSD G6]]: Housekeeping","display":"G6 - Housekeeping"},
                                        {"value":"[[WP:CSD#G7|CSD G7]]: Author request","display":"G7 - Author request"},
                                        {"value":"[[WP:CSD#G8|CSD G8]]: Redundant talk page","display":"G8 - Redundant talk page"},
                                        {"value":"[[WP:CSD#G10|CSD G10]]: Attack page","display":"G10 - Attack page"},
                                        {"value":"[[WP:CSD#G11|CSD G11]]: Advertising","display":"G11 - Advertising"},
                                        {"value":"[[WP:CSD#G12|CSD G12]]: Copyright infringement","display":"G12 - Copyright infringement"},
                                        {"value":"[[WP:CSD#A1|CSD A1]]: No context","display":"A1 - No context"},
                                        {"value":"[[WP:CSD#A3|CSD A3]]: No content","display":"A3 - No content"},
                                        {"value":"[[WP:CSD#A5|CSD A5]]: Transwikied","display":"A5 - Transwikied"},
                                        {"value":"[[WP:CSD#A7|CSD A7]]: Non-notable person","display":"A7 - Non-notable person"},
                                        {"value":"[[WP:CSD#A7|CSD A7]]: Non-notable group","display":"A7 - Non-notable group"},
                                        {"value":"[[WP:CSD#A7|CSD A7]]: Non-notable band","display":"A7 - Non-notable band"},
                                        {"value":"[[WP:CSD#A7|CSD A7]]: Non-notable company","display":"A7 - Non-notable company"},
                                        {"value":"[[WP:CSD#A7|CSD A7]]: Non-notable website","display":"A7 - Non-notable website"},
                                        {"value":"[[WP:CSD#R1|CSD R1]]: Bad target","display":"R1 - Bad target"},
                                        {"value":"[[WP:CSD#R2|CSD R2]]: Cross namespace","display":"R2 - Cross namespace"},
                                        {"value":"[[WP:CSD#R3|CSD R3]]: Typo","display":"R3 - Typo"},
                                        {"value":"[[WP:CSD#I1|CSD I1]]: Redundant","display":"I1 - Redundant"},
                                        {"value":"[[WP:CSD#I2|CSD I2]]: Corrupt","display":"I2 - Corrupt"},
                                        {"value":"[[WP:CSD#I3|CSD I3]]: Improper license","display":"I3 - Improper license"},
                                        {"value":"[[WP:CSD#I4|CSD I4]]: No licensing information","display":"I4 - No licensing information"},
                                        {"value":"[[WP:CSD#I5|CSD I5]]: Unused unfree copyrighted image","display":"I5 - Unused unfree copyrighted image"},
                                        {"value":"[[WP:CSD#I6|CSD I6]]: Missing fair-use rationale","display":"I6 - Missing fair-use rationale"},
                                        {"value":"[[WP:CSD#I7|CSD I7]]: Invalid fair-use claim","display":"I7 - Invalid fair-use claim"},
                                        {"value":"[[WP:CSD#G1|CSD C1]]: Empty","display":"C1 - Empty"},
                                        {"value":"[[WP:CSD#C2|CSD C2]]: Renaming","display":"C2 - Renaming"},
                                        {"value":"[[WP:CSD#U1|CSD U1]]: User request","display":"U1 - User request"},
                                        {"value":"[[WP:CSD#U2|CSD U2]]: Non-existent user","display":"U2 - Non-existent user"},
                                        {"value":"[[WP:CSD#T1|CSD T1]]: Divisive and inflammatory","display":"T1 - Divisive and inflammatory"},
                                        ],
				//**************************** attaching function *****************************************
				// got thIS super handi function from http://www.scottandrew.com he is pretty dang smart **
			        //*****************************************************************************************
				addEvent:function(obj, evType, fn, useCapture){
					//alert(obj);
					if (obj.addEventListener){
						obj.addEventListener(evType, fn, useCapture);
						return true;
					} else if (obj.attachEvent){
						var r = obj.attachEvent("on"+evType, fn);
						return r;
					} else {
						alert("Handler could not be attached");
					}
				}
			}
			function addSelectAfter(){
    				var obj = document.getElementById('wpReason');
    			        // create select using included array
				var sel = document.createElement("SELECT");
				csdDeleteForm .FillSelect(sel, csdDeleteForm .ValueArray);
				// name it
				sel.name = "csdOptions";
				sel.id = "csdOptions";
                                sel.style.marginLeft = "10px";
                                csdDeleteForm .addEvent(sel, "change", csdChangeBox, false);
				// check for next sibling and insert before it or at the end
				if(obj.nextSibling){
					obj.parentNode.insertBefore(sel,obj.nextSibling);
				}else{
					obj.parentNode.appendChild(sel);
				}
			}
			try{
				// add one on load
				csdDeleteForm.addEvent(window, "load", addSelectAfter, false);
			}catch(err){}
}

function csdChangeBox() {
                                                         var obj = document.getElementById('wpReason');
                                                         obj.value = document.getElementById('csdOptions').value;
                                                         }
*/
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Highlight redirects
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var highlightRedirects = {
 
 tab_redirects : null,
 status: null,
 xhr : null,
 todo : null,
 num : { total:0, done:0, redir:0 },

 //
 // Try to create an XMLHTTP request object for each tile
 // with maximum browser compat.
 // code adapted from http://jibbering.com/2002/4/httprequest.html
 //
 createXMLHTTP : function()
 {
  var i, xhr;

  /*@cc_on @*/
  /*@if (@_jscript_version >= 5)
  // Internet Explorer (uses Conditional compilation)
  // traps security blocked creation of the objects.
   wmaDebug('Microsoft section');
   try {
    xhr = new ActiveXObject("Msxml2.XMLHTTP");
   } catch (e) {
    try {
     xhr = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
     xhr = false;
    }
   }
  @end @*/

  // Firefox, Konqueror, Safari, Mozilla
  if (!xhr && typeof(XMLHttpRequest) != 'undefined') {
   try {
    xhr = new XMLHttpRequest();
   } catch (e) {
    xhr = false;
   }
  }

  // ICE browser
  if (!xhr && window.createRequest) {
   try {
    xhr = new window.createRequest();
   } catch (e) {
    xhr = false;
   }
  }

  return xhr;
 },

 updateStatus : function()
 {
  with( highlightRedirects )
  {
   status.nodeValue = ' (' + num.redir + '/' + num.done + '/' + num.total + ')';
  }
 },

 // cross-browser event attachment (John Resig)
 // http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
 addEvent : function ( obj, type, fn )
 {
  if (obj.addEventListener)
   obj.addEventListener( type, fn, false );
  else if (obj.attachEvent)
  {
   obj["e"+type+fn] = fn;
   obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
   obj.attachEvent( "on"+type, obj[type+fn] );
  }
 },

 run : function()
 {
  var links = document.getElementById('bodyContent').getElementsByTagName('a');
  var local = window.location.href + '#'
 
  if( highlightRedirects.todo != null ) return;

  highlightRedirects.todo = new Array();

  for( var key in links )
  {
   if( links[key].href && 
       links[key].pathname &&
       links[key].pathname.substr(0,6) == '/wiki/' &&
       !( links[key].href.substr(0,local.length) == local ) &&
       !( links[key].pathname.substr(6,8) == 'Special:' ) )
   {
    highlightRedirects.todo[highlightRedirects.num.total] =
    {
     link : links[key],
     xhr  : highlightRedirects.createXMLHTTP(),
     func : new Function(
       'var me = highlightRedirects.todo['+highlightRedirects.num.total+'];' + 
       'if(me.xhr.readyState==4) {' +
        'var ro=eval("("+me.xhr.responseText+")");' +
        'var redir=false;' +
        'for( var k in ro.query.pages ) {' + 
         'if( typeof(ro.query.pages[k].redirect) != "undefined" ) redir=true;' +
        '}' +
        'if(redir) {' + 
         'me.link.style.color="green";' +
         'highlightRedirects.num.redir++;' +
        '}' + 
        'else me.link.style.color="blue";' +
        'highlightRedirects.num.done++; highlightRedirects.updateStatus();' +
       '}' 
     )
    }

    links[key].style.color = 'gray';

    with(highlightRedirects.todo[highlightRedirects.num.total])
    {
     xhr.open("GET", 
      "/w/api.php?action=query&prop=info&format=json&titles=" +
      links[key].pathname.substr(6), true);

     xhr.onreadystatechange = func;
     xhr.send( null ); 
    }

    highlightRedirects.num.total++;
   }
  }
 },

 install : function()
 {
  with(highlightRedirects)
  {
   tab_redirects = document.createElement('li');
   tab_redirects.style.cursor = 'pointer';
   tab_redirects.style.padding = '0pt 0.8em 0pt 0.8em';
   tab_redirects.style.color = 'blue';

   status = document.createTextNode('');
   tab_redirects.appendChild( document.createTextNode('redirects') );
   tab_redirects.appendChild( status );

   if( document.getElementById('ca-history') ) 
    document.getElementById('ca-history').parentNode.appendChild( tab_redirects  );

   addEvent( tab_redirects, 'click', run );
  }
 }

};

//
// Hook up installation function
//
$(highlightRedirects.install);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Automatically do stuff
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//addOnloadHook(function(){ var x; if (x=document.getElementById('wpBlockOther')) {x.value=blah;} });

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Edit top
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

hookEvent("load", function ()
{
	if(window.location.href.indexOf("/wiki/Special:") != -1) return;
	if(document.getElementById("wikiPreview")) return;
	if(document.getElementById("histlegend‎")) return;
	if(document.getElementById("difference‎")) return;
	if(document.getElementById("watchdetails")) return;
	if(document.getElementById("mainpage")) return;

	if(window.location.href.indexOf("&action=edit") == -1)
	{
		var pageTitle = document.title.split(" - ")[0].replace(" ", "_");
		var divContainer = document.createElement("div");
		divContainer.innerHTML = '<div class="editsection" style="float:right;">\
[<a \
title="' + document.title.split(" - ")[0] + '">edit</a>]</div>';
		var coos = document.getElementById("coordinates");
		if(coos) coos.style.right = "4.5em";
		document.getElementById("content").insertBefore(
			divContainer, document.getElementsByTagName("h1")[0]);
	}
	else if(window.location.href.indexOf("&action=edit&section=0") != -1)
	{
		e = document.getElementById("wpSummary");
		if(e) e.value = "/* Intro */ ";
	}
});

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addlilink(tabs, url, name, id, title, key){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    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];
        }
    }
    akeytt();
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add toolbox link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addToolboxLink(url, name, id){
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, url, name, id);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    return addlilink(tabs, url, name, id, title, key)
};

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add menu
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get page name
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get tidy title
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function get_tidy_title()
{
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));

  return editlk;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add link
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addLink(where, url, name, id, title, key, after){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        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;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Voice of All tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Master rollback
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Specialadmin/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

$(Dfn_js_con)
function Dfn_js_con()
{
Mvaluejs_class = 'm';
Rvaluejs_class = 'r';
Uvaluejs_class = 'u';
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Sleeper tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//document.write('<script type="text/javascript" src="' 
//             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Sleeper/monobook.js' 
//             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// History analysis
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/History/monobook.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Find and replace
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/replacetxt.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// AfD tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 1
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function autoafd_result()
{
  var close = prompt("Result of debate?")
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
}

function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
  f.wpSummary.value = "Relisting debate";
}

function autoafd_keep()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}

function autoafd_no_consensus()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}

function autoafd_redirect()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_merge()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Merge and redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}

function autoafd_other()
{
  var date = prompt("Nomination was made when?")
  var result = prompt("Result was?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;

    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }

  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
}

function autoafd_add_afd_tabs()
{
  // Only add for pages with the right string somewhere in the title
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge");
      mw.util.addPortletLink('p-cactions', 'javascript:autoafd_other()', "other");
    }
}

$(autoafd_add_afd_tabs);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 2
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

importScript("User:Jnothman/automod.js");
 
afdh_signature = '~~'+'~';
afdh_summaryprompt = true;
afdh_useicons = false;
 
afdh_shortcuts = Object();
afdh_shortcuts['d'] = 'Delete';
afdh_shortcuts['k'] = 'Keep';
afdh_shortcuts['m'] = 'Merge';
afdh_shortcuts['mv'] = 'Move';
afdh_shortcuts['rd'] = 'Redirect';
afdh_shortcuts['rw'] = 'Rewrite';
afdh_shortcuts['t'] = 'Transwiki';
afdh_shortcuts['wd'] = 'Weak delete';
afdh_shortcuts['sd'] = 'Strong delete';
afdh_shortcuts['sp'] = 'Speedy delete';
afdh_shortcuts['sk'] = 'Strong keep';
afdh_shortcuts['wk'] = 'Weak keep';
afdh_shortcuts['spk'] = 'Speedy keep';
afdh_shortcuts['c'] = 'Comment';
 
afdh_icons = Object();
afdh_icons['d'] = afdh_icons['wd'] = afdh_icons['sd'] = afdh_icons['sp'] = 'Symbol delete vote.svg';
afdh_icons['k'] = afdh_icons['sk'] = afdh_icons['wk'] = 'Symbol keep vote.svg';
afdh_icons['m'] = 'Symbol merge vote.svg';
afdh_icons['c'] = 'Symbol comment vote.svg';
 
afdh_commscs = Object();
afdh_commscs['pn'] = 'per nom.';
 
function afd_helper() {
    if (auto_mod())
       return;
 
    var anchors = new Array();
    {
    var oldanchors = document.getElementById('bodyContent').getElementsByTagName('a');
    for (var i=0; i < oldanchors.length; i++)
        anchors[i] = oldanchors[i];
    }
    var url_re = /\?title=Wikipedia:Articles_for_deletion\/([^&]+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors[i].href.match(url_re))
         || (matches[1].substr(0, 4) == 'Log/'))
            continue;
        var na = document.createElement('a');
        na.href = "javascript:afd_vote('"+escape(anchors[i].href)+"')";
        na.title = "Vote on deletion of "+unescape(matches[1]);
        var inlink = document.createElement('sup');
        inlink.appendChild(document.createTextNode('vote'));
        na.appendChild(inlink);
        anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling);
    }
 
    if (am_get_title().indexOf(':') == -1)
        am_add_li('tb', 'javascript:afd_nominate()', 'Nominate AFD', '', 'Nominate this article for deletion');
}
 
function afd_vote(edit_link) {
    var shortcuts_list = '';
    for (var key in afdh_shortcuts)
        shortcuts_list += key + ': ' + afdh_shortcuts[key] + '; ';
    var vote = window.prompt("Enter your vote.   (Shortcuts available are: "+shortcuts_list+")");
    if (!vote) return;
    var icon_link = '';
    if (afdh_useicons && afdh_icons[vote.toLowerCase()])
        icon_link = '[[Image:' + afdh_icons[vote.toLowerCase()] + '|20px]] ';
    if (afdh_shortcuts[vote.toLowerCase()])
        vote = afdh_shortcuts[vote.toLowerCase()];
 
    shortcuts_list = '';
    for (var key in afdh_commscs)
        shortcuts_list += key + ': ' + afdh_commscs[key] + '; ';
    var comment = window.prompt("Enter your comment.  (Shortcuts available are: "+shortcuts_list+")");
    if (typeof comment != 'string') return;
    if (afdh_commscs[comment.toLowerCase()])
        comment = afdh_commscs[comment.toLowerCase()];
 
    var summary = vote;
    if (afdh_summaryprompt)
      if (!(summary = window.prompt("Enter the edit summary:", summary)))
         summary = vote;
    var url = edit_link + 
        '&amaddafter='+escape("* '''"+icon_link+vote+"''' "+comment+" "+afdh_signature+" ~~"+"~~"+"~") +
        '&amsummary='+escape(summary);
 
    if (window.location.href.indexOf("/Log/") == -1)
      window.location.href = url;
    else
      window.open(url, "afd_helper_vote");
}
 
function afd_nominate() {
    var title = am_get_title();
    var log_date = window.prompt("This should be the date of the latest AFD log. Change it if necessary.", am_guess_date());
    if (!log_date)
        return;
    var reason = window.prompt("Please justify your AFD nomination of "+title+":");
    if (!reason)
        return;
    var cat = window.prompt("Please categorize your nomination: M: Media and music; O: Organisation, company, or product; B: Biographical; S: Society; W: Web/Internet; G: Games/Sport; T: Science/Technology; F: Fiction and the arts; P: Places or transportation; I: Unclassifiable; ?: Unsure");
    if (!cat)
        cat="U";
    window.open(am_make_url(title, '{{'+'subst:afd}}', '', 'nomination for [[WP:AFD|deletion]]'), 'afdhn1');
    window.open(am_make_url('Wikipedia:Articles for deletion/Log/'+log_date, '', '{{'+'subst:afd3|pg='+title+'}}', 'Nominating [['+title+']] for deletion') + "&amatstring=TOP+of+the+following+list+-->", 'afdhn3');
    window.location.href = am_make_url('Wikipedia:Articles for deletion/'+title, '', '{{'+'subst:afd2|pg='+title+'|text='+reason+' '+afdh_signature+" ~~"+"~~"+"~"+'|cat='+cat+'}}', 'nominated for deletion');
}
 
$(afd_helper);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 3
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function hideClosedAFD() {
  if ((wgPageName.indexOf('Wikipedia:Articles_for_deletion/Log/') != -1) && (wgAction == "view")) {
    mw.util.addPortletLink('p-cactions', 'javascript:hideClosed()', "hide closed", "ca-hideClosed", "Hide closed discussions");
    mw.util.addPortletLink('p-cactions', 'javascript:showClosed()', "show closed", "ca-showClosed", "Show closed discussions");
    document.getElementById('ca-showClosed').style.display = 'none'; 
  }
}
function hideClosed() {
  var closed = getElementsByClassName(document, "div", "boilerplate metadata afd vfd xfd-closed");
  document.getElementById('ca-hideClosed').style.display = 'none';
  document.getElementById('ca-showClosed').style.display = ''; 
  for (var i in closed)
  {
    closed[i].style.display = 'none';
  }
}
function showClosed() {
  var closed = getElementsByClassName(document, "div", "boilerplate metadata afd vfd xfd-closed");
  document.getElementById('ca-showClosed').style.display = 'none';
  document.getElementById('ca-hideClosed').style.display = ''; 
  for (var i in closed)
  {
    closed[i].style.display = '';
  }
} 
 
$(hideClosedAFD);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Automatic Protection
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

importScript('User:Steel359/^demon.js');
 
function addLink(where, url, name, id, title, key, after) {
    // addLink() accepts either an id or a DOM node, mw.util.addPortletLink() only takes a node
    if (after && !after.cloneNode)
        after = document.getElementById(after);
 
    return mw.util.addPortletLink(where, url, name, id, title, key, after);
}
 
  if (document.title.indexOf("Editing Wikipedia:Requests for page protection (section)") != -1) {
 
function fullprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|p}} ~~" + "~~";
  f.wpSummary.value += "fully protected ";
}
 
// Break
 
function fullprotexp_tag()
{
  var expfull = prompt( "The page protection will expire in..." );
  if( !expfull ) {
  return;
 } else {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|p|" + expfull + "}} ~~" + "~~";
  f.wpSummary.value += "fully protected ";
 }
}
 
// Break
 
function semiprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|s}} ~~" + "~~";
  f.wpSummary.value += "sprotected ";
}
 
// Break
 
function semiprotexp_tag()
{
  var expsemi = prompt( "The page protection will expire in..." );
  if( !expsemi ) {
  return;
 } else {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|s|" + expsemi + "}} ~~" + "~~";
  f.wpSummary.value += "sprotected ";
 }
}
 
// Break
 
function moveprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|m}} ~~" + "~~";
  f.wpSummary.value += "move protected ";
}
 
// Break
 
function declinedprot_tag()
{
  var declinereason = prompt( "Reason? (Optional)" );
  if( !declinereason ) {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|d}} ~~" + "~~";
  f.wpSummary.value += "declined ";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|d}}, " + declinereason + " ~~" + "~~";
  f.wpSummary.value += "declined ";
 }
}
 
// Break
 
function neaprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|nea}} ~~" + "~~";
  f.wpSummary.value += "declined ";
}
 
// Break
 
function faprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|fa}} ~~" + "~~";
  f.wpSummary.value += "declined ";
}
 
// Break
 
function userprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|b}} ~~" + "~~";
  f.wpSummary.value += "user blocked ";
}
 
// Break
 
function unprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|u}} ~~" + "~~";
  f.wpSummary.value += "unprotected ";
}
 
// Break
 
function doneprot_tag()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|do}} ~~" + "~~";
  f.wpSummary.value += "done ";
}
 
// Break
 
function note_tag()
{
  var notereason = prompt ("Note:");
  if ( !notereason) {
  return;
 } else {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value +=":{" + "{RFPP|n}} " + notereason + " ~~" + "~~";
  f.wpSummary.value += "note ";
 }
}
 
function prot_tagging()
{
  mw.util.addPortletLink('p-navigation', 'javascript:fullprot_tag()', "(Fully protected)");
  mw.util.addPortletLink('p-navigation', 'javascript:fullprotexp_tag()', "(Full) \+ expiry");
  mw.util.addPortletLink('p-navigation', 'javascript:semiprot_tag()', "(Semi-protected)");
  mw.util.addPortletLink('p-navigation', 'javascript:semiprotexp_tag()', "(Semi) \+ expiry");
  mw.util.addPortletLink('p-navigation', 'javascript:moveprot_tag()', "(Move-protected)");
  mw.util.addPortletLink('p-navigation', 'javascript:declinedprot_tag()', "(Declined)");
  mw.util.addPortletLink('p-navigation', 'javascript:neaprot_tag()', "(Declined nea)");
  mw.util.addPortletLink('p-navigation', 'javascript:faprot_tag()', "(Declined fa)");
  mw.util.addPortletLink('p-navigation', 'javascript:userprot_tag()', "(User blocked)");
  mw.util.addPortletLink('p-navigation', 'javascript:unprot_tag()', "(Unprotected)");
  mw.util.addPortletLink('p-navigation', 'javascript:doneprot_tag()', "(Done)");
  mw.util.addPortletLink('p-navigation', 'javascript:note_tag()', "(Note)");
}
 
$(prot_tagging);
importStylesheet('User:Steel359/protection2.css');
 
// End if
};
 
// ---------------------------------------------------------------------------------------------------------------
//                                                                                                Protection tags
 
	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};
 
function misc_tagging()
{
  mw.util.addPortletLink('p-tb', mw.config.get('wgServer') + '/wiki/Wikipedia:Requests for page protection', "WP:RFPP");
}
 
$(misc_tagging);
 
// ----------------------------------------------------------
 
// pp-dispute
 
$(function (){
  if(queryString("jsaction")=="pp-dispute") {
  var fulldisputeexp = prompt( "Expiry time? (Optional)" );
  if ( fulldisputeexp == null ) {
  return;
 } else if ( fulldisputeexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-dispute}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-dispute}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-dispute|expiry={" + "{subst:#time:F j, Y|\+" + fulldisputeexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-dispute}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-vandalism
 
$(function (){
  if(queryString("jsaction")=="pp-vandalism") {
  var fullvandalexp = prompt ("Expiry time? (Optional)");
  if ( fullvandalexp == null ) {
  return;
 } else if ( fullvandalexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-vandalism}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-vandalism}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-vandalism|expiry={" + "{subst:#time:F j, Y|\+" + fullvandalexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-vandalism}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-usertalk
 
$(function (){
  if(queryString("jsaction")=="pp-usertalk") {
  var fulltalkexp = prompt ("Expiry time? (Optional)");
  if ( fulltalkexp == null ) {
  return;
 } else if ( fulltalkexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-usertalk}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-usertalk}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-usertalk|expiry={" + "{subst:#time:F j, Y|\+" + fulltalkexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-usertalk}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-protected (other)
 
$(function (){
  if(queryString("jsaction")=="pp-protected") {
  var fullreason = prompt ( "This page is currently protected from editing because... (Optional)" );
  if ( fullreason == null ) {
  return;
 } else if ( fullreason == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-protected}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-protected}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-protected|reason=" + fullreason + "}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-protected}}";
 }
 
  var fullotherexp = prompt ( "Expiry time? (Optional)");
  if ( fullotherexp == null ) {
  return;
 } else if ( fullotherexp == '' ) {
  document.forms[0].wpSave.click();
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.split('{'+'{pp-protected').join('{'+'{pp-protected|expiry={{subst:#time:F j, Y|\+' + fullotherexp + "}}" );
  document.forms[0].wpSave.click();
 }
}
});
 
// pp-small=yes
 
$(function (){
  if(queryString("jsaction")=="pp-small") {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-protected|small=yes}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-protected|small=yes}}";
  document.forms[0].wpSave.click();
 }
});
 
// pp-semi-vandalism
 
$(function (){
  if(queryString("jsaction")=="pp-semi-vandalism") {
  var semivandalexp = prompt( "Expiry time? (Optional)" );
  if ( semivandalexp == null ) {
  return;
 } else if ( semivandalexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-vandalism}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-vandalism}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-vandalism|expiry={" + "{subst:#time:F j, Y|\+" + semivandalexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-vandalism}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-semi-usertalk
 
$(function (){
  if(queryString("jsaction")=="pp-semi-usertalk") {
  var semitalkexp = prompt ("Expiry time? (Optional)");
  if ( semitalkexp == null ) {
  return;
 } else if ( semitalkexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-usertalk}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-usertalk}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-usertalk|expiry={" + "{subst:#time:F j, Y|\+" + semitalkexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-usertalk}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-semi-socks
 
$(function (){
  if(queryString("jsaction")=="pp-semi-sock") {
  var semisockexp = prompt( "Expiry time? (Optional)" );
  if ( semisockexp == null ) {
  return;
 } else if ( semisockexp == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-sock}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-sock}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-sock|expiry={" + "{subst:#time:F j, Y|\+" + semisockexp + "}}}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-sock}}";
 }
  document.forms[0].wpSave.click();
 }
});
 
// pp-semi-protected (other)
 
$(function (){
  if(queryString("jsaction")=="pp-semi-protected") {
  var semireason = prompt ( "Editing of this article by unregistered or newly registered users is currently disabled because... (Optional)" );
  if ( semireason == null ) {
  return;
 } else if ( semireason == '' ) {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-protected}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-protected}}";
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-protected|reason=" + semireason + "}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-protected}}";
 }
 
  var semiotherexp = prompt ( "Expiry time? (Optional)");
  if ( semiotherexp == null ) {
  return;
 } else if ( semiotherexp == '' ) {
  document.forms[0].wpSave.click();
 } else {
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.split('{'+'{pp-semi-protected').join('{'+'{pp-semi-protected|expiry={{subst:#time:F j, Y|\+' + semiotherexp + "}}" );
  document.forms[0].wpSave.click();
 }
}
});
 
// pp-semi-small=yes
 
$(function (){
  if(queryString("jsaction")=="pp-semi-small") {
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{" + "{pp-semi-protected|small=yes}}" + '\n' + t.value;
  f.wpSummary.value = "{" + "{pp-semi-protected|small=yes}}";
  document.forms[0].wpSave.click();
 }
});
 
// Unprotection
 
$(function (){
  if(queryString("jsaction")=="unprotected") {
  var f = document.editform, t = f.wpTextbox1;
  var pp = RegExp("\{\{pp-.*?\}\}.*?\n");
  t.value = t.value.split(pp).join('');
  f.wpSummary.value = "Unprotected";
  var unprotconfirm = confirm( "This script removes new style protection templates (eg, {"+"{pp-whatever}}), but not the older versions." + "\n" + "If an old style protection template is still present (eg, {"+"{sprotect}}), hit cancel to remove it manually, otherwise hit OK to save the page." );
  if( !unprotconfirm ) {
  return;
 } else {
  document.forms[0].wpSave.click();
 }
}
});
 
// ---------------------------------------------------------------------------------------------------------
 
  if ( wgNamespaceNumber > -1 ) {
 
function mylinks() {
 var boxclone = document.createElement("div");
 boxclone.id = 'p-navclone';
 boxclone.setAttribute("class","portlet");
 boxclone.style.marginTop = "7px";
 boxclone.style.marginBottom = "1px";
 
 var titolo = document.createElement("h5");
 titolo.innerHTML = "protection tags";
 boxclone.appendChild(titolo);
 
 var corpo = document.createElement("div");
 corpo.setAttribute("class","pBody");
 var list_ul = document.createElement("ul");
 
 var list_b = document.createElement("li");
 list_b.id = 'v-dispute';
 var link_b = document.createElement("a");
 link_b.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-dispute';
 link_b.innerHTML = 'Full (dispute)';
 list_b.appendChild(link_b);
 list_ul.appendChild(list_b);
 
 var list_e = document.createElement("li");
 list_e.id = 'v-vandalism';
 var link_e = document.createElement("a");
 link_e.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-vandalism';
 link_e.innerHTML = 'Full (vandalism)';
 list_e.appendChild(link_e);
 list_ul.appendChild(list_e);
 
 var list_e = document.createElement("li");
 list_e.id = 'v-usertalk';
 var link_e = document.createElement("a");
 link_e.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-usertalk';
 link_e.innerHTML = 'Full (unblockabuse)';
 list_e.appendChild(link_e);
 list_ul.appendChild(list_e);
 
 var list_j = document.createElement("li");
 list_j.id = 'v-protected';
 var link_j = document.createElement("a");
 link_j.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-protected';
 link_j.innerHTML = 'Full (other)';
 list_j.appendChild(link_j);
 list_ul.appendChild(list_j);
 
 var list_j = document.createElement("li");
 list_j.id = 'v-small';
 var link_j = document.createElement("a");
 link_j.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-small';
 link_j.innerHTML = 'Full (small=yes)';
 list_j.appendChild(link_j);
 list_ul.appendChild(list_j);
 
 var list_k = document.createElement("li");
 list_k.id = 'v-s-vandalism';
 var link_k = document.createElement("a");
 link_k.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-semi-vandalism';
 link_k.innerHTML = 'Semi (vandalism)';
 list_k.appendChild(link_k);
 list_ul.appendChild(list_k);
 
 var list_e = document.createElement("li");
 list_e.id = 'v-s-usertalk';
 var link_e = document.createElement("a");
 link_e.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-semi-usertalk';
 link_e.innerHTML = 'Semi (unblockabuse)';
 list_e.appendChild(link_e);
 list_ul.appendChild(list_e);
 
 var list_l = document.createElement("li");
 list_l.id = 'v-s-socks';
 var link_l = document.createElement("a");
 link_l.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-semi-sock';
 link_l.innerHTML = 'Semi (sock problems)';
 list_l.appendChild(link_l);
 list_ul.appendChild(list_l);
 
 var list_l = document.createElement("li");
 list_l.id = 'v-s-protected';
 var link_l = document.createElement("a");
 link_l.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-semi-protected';
 link_l.innerHTML = 'Semi (other)';
 list_l.appendChild(link_l);
 list_ul.appendChild(list_l);
 
 var list_j = document.createElement("li");
 list_j.id = 'v-small';
 var link_j = document.createElement("a");
 link_j.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=pp-semi-small';
 link_j.innerHTML = 'Semi (small=yes)';
 list_j.appendChild(link_j);
 list_ul.appendChild(list_j);
 
 var list_l = document.createElement("li");
 list_l.id = 'v-unprot';
 var link_l = document.createElement("a");
 link_l.href = mw.config.get('wgServer') + '/wiki/' + wgPageName + '?action=edit&jsaction=unprotected';
 link_l.innerHTML = 'Unprotected';
 list_l.appendChild(link_l);
 list_ul.appendChild(list_l);
 
 corpo.appendChild(list_ul);
 boxclone.appendChild(corpo);
 document.getElementById("p-tb").appendChild(boxclone);
}
 
if (window.addEventListener) window.addEventListener("load",mylinks,false);
else if (window.attachEvent) window.attachEvent("onload",mylinks);
 
 
};


//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Tab customisation tools
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab tools (technical)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function edit_summary_watch(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += msg;
  f.wpSummary.value = summ;
}

function edit_summary_watch2(summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = summ;
}

function edit_summary_watch3(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = msg;
  f.wpSummary.value = summ;
}

/* function testn(number)
{
  var page = prompt("Which message do you want to issue?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:Xy7/" + page + "}} ~" + "~" + "~";
  t.value += '\n';
  f.wpSummary.value = "vandalism warning";
} */

function unblockuser(msg, other)
{
  var f = document.getElementsByName('wpUnblockReason')[0];
  f.value = msg;
}

function testv(number)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = "";
}

function protected(){
    var form = document.editform;
    form.wpSummary.value = '{{protected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{protected}} \n' + txt.value;
}

function vprotected(){
    var form = document.editform;
    form.wpSummary.value = '{{vprotected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{vprotected}} \n' + txt.value;
}

function sprotected(){
    var form = document.editform;
    form.wpSummary.value = '{{sprotected}}';
    var txt = form.wpTextbox1;
    txt.value = '{{sprotected}} \n' + txt.value;
}

function deletedpage(){
    var form = document.editform;
    form.wpSummary.value = '{{deletedpage}}';
    var txt = form.wpTextbox1;
    txt.value = '{{deletedpage}} \n' + txt.value;
}

function usertalkvprotect(){
    var form = document.editform;
    form.wpSummary.value = '{{usertalk-vprotect}}';
    var txt = form.wpTextbox1;
    txt.value = '{{usertalk-vprotect}} \n' + txt.value;
}

function usertalksprotect(){
    var form = document.editform;
    form.wpSummary.value = '{{usertalk-sprotect}}';
    var txt = form.wpTextbox1;
    txt.value = '{{usertalk-sprotect}} \n' + txt.value;
}

function archive(){
    var form = document.editform;
    form.wpSummary.value = 'archive';
    var txt = form.wpTextbox1;
    txt.value = '{{subst:User:Xy7/AT}} \n' + txt.value;
}

function blockuser(time, week, msg, reason, anon, creation)
{
  var j = document.getElementsByName('wpBlockExpiry')[0];
  j.value = time;
  var w = document.getElementsByName('wpBlockOther')[0];
  w.value = week;
  var f = document.getElementsByName('wpBlockReasonList')[0];
  f.value = msg;
  var r = document.getElementsByName('wpBlockReason')[0];
  r.value = reason;
  var o = document.getElementsByName('wpAnonOnlyRow')[0];
  o.checked = anon;
  var p = document.getElementsByName('wpCreateAccountRow')[0];
  p.checked = creation;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add tab tools (the actual tabs)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

  if (document.title.indexOf("Block user") == 0)
    {
	addlilink(tabs, 'javascript:blockuser("other", "24 hours", "Other reason", "vandalism", "checked", "checked")', "24 hours");
	addlilink(tabs, 'javascript:blockuser("other", "48 hours", "Other reason", "vandalism", "checked", "checked")', "48 hours");
	addlilink(tabs, 'javascript:blockuser("other", "96 hours", "Other reason", "vandalism", "checked", "checked")', "96 hours");
	addlilink(tabs, 'javascript:blockuser("other", "1 week", "Other reason", "vandalism", "checked", "checked")', "1 week");
	addlilink(tabs, 'javascript:blockuser("other", "2 weeks", "Other reason", "vandalism", "checked", "checked")', "2 weeks");
	addlilink(tabs, 'javascript:blockuser("other", "4 weeks", "Other reason", "vandalism", "checked", "checked")', "4 weeks");
	addlilink(tabs, 'javascript:blockuser("other", "8 weeks", "Other reason", "vandalism", "checked", "checked")', "8 weeks");
	addlilink(tabs, 'javascript:blockuser("other", "12 weeks", "Other reason", "vandalism", "checked", "checked")', "12 weeks");
	addlilink(tabs, 'javascript:blockuser("other", "16 weeks", "Other reason", "vandalism", "checked", "checked")', "16 weeks");
	addlilink(tabs, 'javascript:blockuser("other", "indefinite", "Other reason", "vandalism", "checked", "checked")', "indefinite");
    }

/*

  if (document.title.indexOf("Editing User talk:") != -1)
    {
      addlimenu(tabs, '...templates...', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/w/v/1}}", "vandalism warning (1)", true, 1)',"vand: 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/w/v/2}}", "vandalism warning (2)", true, 1)',"vand: 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/w/v/3}}", "vandalism warning (3)", true, 1)',"vand: 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/w/v/4}}", "vandalism warning (4)", true, 1)',"vand: 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/t/v}}", "blocked (vandalism)", true, 1)',"v: temp");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/i/v}}", "blocked (vandalism)", true, 1)',"v: indef");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/i/u}}", "blocked (username)", true, 1)',"username");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/i/uv}}", "blocked (username/vandalism)", true, 1)',"user/vand");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/block/t/r}}", "blocked (three-revert rule violation)", true, 1)',"revert");
    }

  if (document.title.indexOf("Editing User talk:") != -1)
    {
      addlimenu(tabs, 'vandalism', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Test1}}", "vandalism warning (1)", true, 1)',"test 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Test2}}", "vandalism warning (2)", true, 1)',"test 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Test3}}", "vandalism warning (3)", true, 1)',"test 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Test4}}", "vandalism warning (4)", true, 1)',"test 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/b}}", "blocked (vandalism)", true, 1)',"test 5");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/i}}", "blocked (vandalism)", true, 1)',"test 6");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/1a}}", "message", true, 1)',"date");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/0}}", "possible vandalism warning (0)", true, 1)',"test 0");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Self}}", "vandalism warning (1)", true, 1)',"testself");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/BV}}", "vandalism warning (bv)", true, 1)',"bvandal");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/RV}}", "vandalism warning (rv)", true, 1)',"rvandal");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Blank1}}", "vandalism warning (1)", true, 1)',"blank 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Blank2}}", "vandalism warning (2)", true, 1)',"blank 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Blan3}}", "vandalism warning (3)", true, 1)',"blank 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Blank4}}", "vandalism warning (4)", true, 1)',"blank 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Blank5}}", "blocked (blanking)", true, 1)',"blank 5");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tpv}}", "userpage vandalism warning (1)", true, 1)',"user 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tpv2}}", "userpage vandalism warning (2)", true, 1)',"user 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tpv3}}", "userpage vandalism warning (3)", true, 1)',"user 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tpv4}}", "userpage vandalism warning (4)", true, 1)',"user 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tpv5}}", "blocked (userpage vandalism)", true, 1)',"user 5");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/wr}}", "removing warnings warning (1)", true, 1)',"wr 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/wr2}}", "removing warnings warning (2)", true, 1)',"wr 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/wr3}}", "removing warnings warning (3)", true, 1)',"wr 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/wr4}}", "removing warnings warning (4)", true, 1)',"wr 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/t0}}", "creating inappropriate articles warning (0)", true, 1)',"create 0");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/t1}}", "creating inappropriate articles warning (1)", true, 1)',"create 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/t2}}", "creating inappropriate articles warning (2)", true, 1)',"create 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/t3}}", "creating inappropriate articles warning (3)", true, 1)',"create 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/t4}}", "creating inappropriate articles warning (4)", true, 1)',"create 4");
    }

  if (document.title.indexOf("Editing User talk:") != -1)
    {
      addlimenu(tabs, 'messages', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/1a}}", "message", true, 1)',"date");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/u}}", "blocked (username)", true, 1)',"unb");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/f}}", "blocked (username - non-latin characters)", true, 1)',"latin");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/w}}", "welcome", true, 1)',"welc");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/email}}", "welcome + note", true, 1)',"email");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Anon}}", "welcome", true, 1)',"anon");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Spam1}}", "spam warning (1)", true, 1)',"spam 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Spam2}}", "spam warning (2)", true, 1)',"spam 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Span3}}", "spam warning (3)", true, 1)',"spam 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/Spam4}}", "spam warning (3)", true, 1)',"spam 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/bs}}", "blocked (spam)", true, 1)',"spam 5");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/3RR1}}", "three revert rule warning (1)", true, 1)',"3RR 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/3RR2}}", "three revert rule warning (2)", true, 1)',"3RR 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/3RR3}}", "blocked (three revert rule)", true, 1)',"3RR 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/c1}}", "civility (1)", true, 1)',"civil 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/c2}}", "civility (2)", true, 1)',"civil 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/npa1}}", "no personal attacks (1)", true, 1)',"npa 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/npa2}}", "no personal attacks (2)", true, 1)',"npa 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/npa3}}", "no personal attacks (3)", true, 1)',"npa 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/drm}}", "disprupting AfD process (1)", true, 1)',"afd 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/drm2}}", "disprupting AfD process (2)", true, 1)',"afd 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/drm3}}", "disprupting AfD process (3)", true, 1)',"afd 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/drm4}}", "disprupting AfD process (4)", true, 1)',"afd 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/drm5}}", "blocked (disprupting AfD process)", true, 1)',"afd 5");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/summary}}", "summary", true, 1)',"summ.");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/preview}}", "preview", true, 1)',"prev.");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tilde}}", "sign your posts", true, 1)',"tilde");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/subst}}", "subst", true, 1)',"subst");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/tilde}}", "sign your posts", true, 1)',"tilde");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:EA-welcome|~~~}}", "welcome to Esperanza", true, 1)',"esp");
      addlilink(talkm,'javascript:usertalkvprotect()',"vprot");
      addlilink(talkm,'javascript:usertalksprotect()',"sprot");
      addlilink(talkm,'javascript:archive()',"1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:Xy7/AB}}", "archive", true, 1)',"2");
    }

  if (document.title.indexOf("Editing User:") != -1)
    {
      addlimenu(tabs, 'userpage tags', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:ibu}}", "blocked", true, 1)',"indefinite");
      addlilink(talkm,'javascript:edit_summary_watch("{{indefblocked-username}}", "username block", true, 1)',"username");
      addlilink(talkm,'javascript:edit_summary_watch("{{indefblocked-vandalism}}", "blocked", true, 1)',"vandalism");
      addlilink(talkm,'javascript:edit_summary_watch("{{indef-latin}}", "username block", true, 1)',"non-latin");
      addlilink(talkm,'javascript:edit_summary_watch("{{pageblankvandal}}", "pageblankvandal", true, 1)',"page blank");
      addlilink(talkm,'javascript:edit_summary_watch("{{pagemovevandal}}", "pagemovevandal", true, 1)',"page move");
    }

*/

  if (document.title.indexOf("Editing Image:") == 0)
    {
      addlilink(tabs, 'javascript:edit_summary_watch("{{subst:nld}}", "no licence", true, 1)',"licence");
    }

  if (document.title.indexOf("Editing User:") == 0)
    {
      addlilink(tabs, 'javascript:testv(1)',"");
    }

  if (document.title.indexOf("Editing User talk:") == 0)
    {
      addlilink(tabs, 'javascript:testv(1)',"");
    }

  if (document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0)
    {
        addlilink(tabs, 'javascript:closeafd(prompt("Result"), (prompt("Additional comments")))', 'Result');
    }
         
  if (document.title.indexOf("Editing User:Xy7/status") == 0)
    {
      addlimenu(tabs, 'c/s', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:Xy7/Status2|in}}", "changing status (in)", true, 1)',"i");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:Xy7/Status2|out}}", "changing status (out)", true, 1)',"o");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:Xy7/Status2|around}}", "changing status (around)", true, 1)',"a");
      addlilink(talkm,'javascript:edit_summary_watch3("{{User:Xy7/Status2|busy}}", "changing status (busy)", true, 1)',"b");
    }

  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism") == 0)
    {
      addlimenu(tabs, 'admin intervention against vandalism', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch2("blocked, list empty", true, 1)',"blocked, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("blocked, list not empty", true, 1)',"blocked, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, content dispute, list empty", true, 1)',"content dispute, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, content dispute, list not empty", true, 1)',"content dispute, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not vandalised since final warning", list empty", true, 1)',"no edit since warning, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not vandalised since final warning", true, 1)',"no edit since warning, not empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not been sufficiently warned", list empty", true, 1)',"not sufficiently warned, empty");
      addlilink(talkm,'javascript:edit_summary_watch2("not blocked, has not been sufficiently warned", true, 1)',"not sufficiently warned, not empty");
    }

  if (document.title.indexOf("Editing Category") == 0)
    {
      addlimenu(tabs, 'cat', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch2("renaming of category per [[Wikipedia:Categories for discussion]]", true, 1)',"!");
    }

  if (document.title.indexOf("Editing") == 0)
    {
      addlimenu(tabs, 'protected', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:protected()',"dispute");
      addlilink(talkm,'javascript:vprotected()',"vprotect");
      addlilink(talkm,'javascript:sprotected()',"sprotect");
      addlilink(talkm,'javascript:deletedpage()',"deleted");
    }

  if (document.title.indexOf("Unblock user") == 0)
    {
	addlilink(tabs, 'javascript:unblockuser("temporarily removing block to change duration")', "change duration");
	addlilink(tabs, 'javascript:unblockuser("unblock requested (via email)")', "email");
	addlilink(tabs, 'javascript:unblockuser("blocked mistakenly")', "mistake");
	addlilink(tabs, 'javascript:unblockuser("collateral damage")', "collateral");
	addlilink(tabs, 'javascript:unblockuser("release autoblock")', "autoblock");
    }

  if (document.title.indexOf("Confirm delete") == 0)
    {
      addlilink(tabs, 'javascript:afddelete()',"afd");
      addlilink(tabs, 'javascript:cfddelete()',"cfd");
    }

  if (document.title.indexOf("Editing Talk:") == 0)
    {
      addlilink(tabs, 'javascript:afdresult()',"afd");
    }

}

if (window.addEventListener)
  window.addEventListener("load", add_tabs, false);
else if (window.attachEvent)
  window.attachEvent("onload", add_tabs);
  
function addtab(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Edit section zero
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
  if (!document.getElementById) return;
  x = document.getElementById('ca-edit');
  if(!x) return;
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  if (x.className == 'selected') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected';
    } else {
      x.className = 'selected istalk';
    }
  } else if (x.className == 'selected istalk') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected istalk';
    } else {
      y.className = 'istalk';
    }
  } else {
    y.className = x.className;
    x.className = 'istalk';
  }
  z = document.createElement('A');
  if (x.children) {
    z.href = x.children[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.href = x.childNodes[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
  }
}

if (document.title.indexOf("Editing ") == -1) {
  if (window.addEventListener) window.addEventListener("load", addEditSection0, false);
  else if (window.attachEvent) window.attachEvent("onload", addEditSection0);
}

function getPname() {
  z=document.getElementById("content").childNodes;
  for (var n=0;n<z.length;n++) { 
    if (z[n].className=="firstHeading") return z[n].textContent;
  };
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Block, unblock, and block log tabs
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  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);

  addlilink(tabs, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'u');
  addlilink(tabs, '/w/index.php?title=Special:Blockip&ip=' + editlk, 'b');
  addlilink(tabs, '/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'l');

}

function do_onload()
{
  if (document.title.indexOf('User:') == 0
      || document.title.indexOf('User talk:') == 0)
    add_block_tab();
  //else if (document.title.indexOf('Block user') == 0) // could stand to be more robust
    //do_blockip_stuff();
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Visual aids and changes to personal menus
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Personal menu, navigation, toolbox and more tab customisation
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

if ( document.createElement && window.addEventListener )
{
 function SoFixItInit()
 {

 }

 function SoFixItLoad()
 {
 UserMenu = new PortletMenu( 'p-personal'   );
 PageMenu = new PortletMenu( 'p-cactions'   );
  NavMenu = new PortletMenu( 'p-navigation' );
  ToolMenu = new PortletMenu( 'p-tb'         );

 function GetByClass( sElem, sClass )
 { var i, a2 = [], a = document.getElementsByTagName( sElem );
 for ( i = 0; i < a.length; i++ )
 if ( a[ i ].className == sClass )
 a2.push( a[ i ] );
 return a2;
 }
 var a, td = GetByClass( 'td', 'diff-otitle' );
 if ( ( td = td[ 0 ] ) && ( a = td.getElementsByTagName( 'a' )[ 0 ] ) )
 a.href = a.href + '&action=edit'; // need to change text, later

 var userName = UserMenu.getText( 'pt-userpage' );

 UserMenu.setText( 'pt-mytalk'     , 'Talk'  );
 UserMenu.setText( 'pt-preferences', 'Preferences' );
 UserMenu.setText( 'pt-watchlist'  , 'Watchlist' );
 UserMenu.setText( 'pt-mycontris'  , 'Contributions' );
 UserMenu.setText( 'pt-logout'     , 'Log out'   );

 document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0].style.textTransform = 'none';

 UserMenu.append( 'pt-utc', UTCTime(), 'javascript:void UserMenu.setText("pt-utc",UTCTime())' );

 if ( PageMenu[ 'ca-history' ] ) // theory: if it has a history tab, then it's purgable
 {
 PageMenu.insertBefore( 'ca-history', 'ca-lastdiff', 'last',
 PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'diff=0' ) );

 PageMenu.getHref( 'ca-history' ).replace( /action=history/, 'action=purge');

                        PageMenu.setText( 'ca-edit'     , 'Edit this page'   );

                        PageMenu.setText( 'ca-history'     , 'History'   );

                        PageMenu.setText( 'ca-delete'     , 'Delete'   );
 }

 var x = 1;
 NavMenu.append( 'n-' + x++, 'monobook.js', 'http://en.wikipedia.org/w/index.php?title=User:Xy7/monobook.js&action=edit' );
 NavMenu.append( 'n-' + x++, 'monobook.css', 'http://en.wikipedia.org/w/index.php?title=User:Xy7/monobook.css&action=edit' );
 NavMenu.append( 'n-' + x++, 'XyBot userpage', 'http://en.wikipedia.org/wiki/User:XyBot' );
 NavMenu.append( 'n- ' + x++, 'Purge', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=purge' );
 ToolMenu.append( 'n-' + x++, 'Block IP', 'http://en.wikipedia.org/wiki/Special:Blockip' );
 ToolMenu.append( 'n-' + x++, 'Unblock IP', 'http://en.wikipedia.org/w/index.php?title=Special:Ipblocklist&action=unblock' );
 ToolMenu.append( 'n-' + x++, 'IP block list', 'http://en.wikipedia.org/wiki/Special:Ipblocklist' );
 ToolMenu.append( 'n-' + x++, 'Autoblocks', 'http://tools.wikimedia.de/~pgk/autoblock.php?autoblock=&blocker=FireFox&blockee=&time=0&Submit=Submit+Query' );
 ToolMenu.append( 'n-' + x++, 'Requests: AIV', 'http://en.wikipedia.org/wiki/Wikipedia:Administrator_intervention_against_vandalism' );
 ToolMenu.append( 'n-' + x++, 'Requests: Unblock', 'http://en.wikipedia.org/wiki/Category:Requests_for_unblock' );
 ToolMenu.append( 'n-' + x++, 'Requests: Helpme', 'http://en.wikipedia.org/wiki/Category:Wikipedians_looking_for_help' );
 ToolMenu.append( 'n-' + x++, 'Requests: Adminship', 'http://en.wikipedia.org/wiki/Wikipedia:Requests_for_adminship' );
 ToolMenu.append( 'n-' + x++, 'Speedy deletions', 'http://en.wikipedia.org/wiki/Category:Candidates_for_speedy_deletion' );
 ToolMenu.append( 'n-' + x++, 'AfDs to be closed', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Old' );
 ToolMenu.append( 'n-' + x++, 'Todays AfDs', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Log/Today' );
 ToolMenu.append( 'n-' + x++, 'Yesterdays AfDs', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Log/Yesterday' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard: Incidents', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard/Incidents' );
 ToolMenu.append( 'n-' + x++, 'Noticeboard: 3RR', 'http://en.wikipedia.org/wiki/Wikipedia:Administrators%27_noticeboard/3RR' );
 ToolMenu.append( 'n-' + x++, 'Edit count', 'http://tools.wikimedia.de/~essjay/edit_count/Count.php' );
 ToolMenu.append( 'n-' + x++, 'New users', 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=newusers&user=&page=&limit=20&offset=0' );
  if (document.title.indexOf("User talk:") == 0)
    {
 NavMenu.append( 'n-' + x++, 'Test 1', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=1' );
 NavMenu.append( 'n-' + x++, 'Test 2', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=3' );
 NavMenu.append( 'n-' + x++, 'Test 3', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=5' );
 NavMenu.append( 'n-' + x++, 'Test 4', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=6' );
 NavMenu.append( 'n-' + x++, 'Test 1 + date', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=2' );
 NavMenu.append( 'n-' + x++, 'Test 2 + date', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=4' );
 NavMenu.append( 'n-' + x++, 'Block - temporary', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=7' );
 NavMenu.append( 'n-' + x++, 'Block - indefinite', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=8' );
 NavMenu.append( 'n-' + x++, 'Block - username', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=edit&warn=9' );
    }
 }

 function PortletMenu( id ) // constructor
 {
 this.menu = document.getElementById( id );
 this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc.

 var LIs = this.list.getElementsByTagName( 'li' );

 for ( var i = 0; i < LIs.length; i++ )
 {
 this[ LIs[ i ].id ] = LIs[ i ];
 }

 this.newItem = function( id, txt, url )
 { var li = document.createElement( 'li' ); li.id   = id;
 var  a = document.createElement( 'a'  );  a.href = url;

  a.appendChild( document.createTextNode( txt ) );
 li.appendChild( a );

 this[ id ] = li; // watch this!!!

 return li;
 }

 this.append = function( id, txt, url )
 { this.list.appendChild( this.newItem( id, txt, url ) );
 }
 
 this.insertBefore = function( old, id, txt, url )
 { this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] );
 }

 this.getText = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
 this.setText = function( id, txt ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }

 this.getHref = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href       }
 this.setHref = function( id, url ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
 
 }

 function RemoveNode( id )
 { var node = document.getElementById( id )
 node.parentNode.removeChild( node );
 }

 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Personal menu clock
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 function UTCTime()
 {
 var s = '',
 d = new Date(),
 a = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
 return d.getUTCDate() + ' ' +
 a[ d.getUTCMonth() ] + ' ' +
 d.getUTCFullYear() + ' ' +
 ( '0' + d.getUTCHours()   ).substr( -2 ) + ':' +
 ( '0' + d.getUTCMinutes() ).substr( -2 ) + ' ' + 'UTC';
 }

 SoFixItInit();
 window.addEventListener( 'load', SoFixItLoad, false );
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Page logs link in toolbox
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

$(function () {

 var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?#]*)/;
 ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');
 
 if( (window.location.href.indexOf("User:") != -1) || (window.location.href.indexOf("User_talk:") != -1) ) {
  regDropSubpages = /[User|User_talk]:([^&?\/]*)[\/]?.*/;
  user = regDropSubpages.exec(ptitle)[1];
  url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&user=" + user;
 } else if(window.location.href.indexOf("Special:") != -1) {
  return;
 } else {
  url = "http://en.wikipedia.org/w/index.php?title=Special%3ALog&page=" + ptitle;
 }
 
 tabs = document.getElementById('p-tb').getElementsByTagName('ul')[0];
 l = addlilink(tabs, url, "Logs", "pt-logs");

});

document.write('<style type="text/css">' +
    ' .xdiff { width: 100%; background: white; }' +
    ' .xdiff-row { width: 100%; margin: 0 0 3px 0; overflow: hidden; }' +
    ' .xdiff-col { width: 49%; margin: 0; float: left; clear: none; position: relative; }' +
    ' .xdiff-sign, .xdiff-outer, .xdiff-inner { display: block; margin: 0; }' +
    ' .xdiff-sign { position: absolute; top: 0; left: 0; width: 2em; text-align: center; }' +
    ' .xdiff-outer { padding: 0 0 0 2em; }' +
    ' .xdiff-inner { overflow: auto; overflow-y: visible; width: 100%; }' +
    ' .xdiff-inner.diff-addedline { font-size: 85%; background: #cfc; }' +
    ' .xdiff-inner.diff-deletedline { font-size: 85%; background: #ffa; }' +
    ' .xdiff-inner.diff-context { font-size: 85%; background: #eee; }' +
    (!document.recalc ? '' :  // IE kluge:
        ' * html .xdiff-inner { padding-bottom: expression(this.scrollWidth > this.offsetWidth ? "16px" : 0); }' +
        ' * html .xdiff-sign { top: expression((this.parentNode.clientHeight - this.offsetHeight)/2 + "px"); }') +
    '<'+'/style>');

$(maybeStart);
$(addMarvin);

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Other / Uncategorised
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Interiot edit count (tool 2)
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js&action=raw&ctype=text/javascript'); }

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// End
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* 

*/