User:Aksi great/monobook.js

From Wikipedia, the free encyclopedia

Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.

//<pre><nowiki>

var sr$t;
var sr$f;
var sr$s;
var sr$r;
var sr$w;
var sr$i;
var sr$re;
var sr$mc;

function $e(id) {return document.getElementById(id)}

function srBack()
{
  if (sr$s.value=='') {sr$t.focus(); return }

  if (sr$re.checked) {
    var searchString = sr$s.value;
  } else {
    searchString=sr$s.value.replace(/([\[\]\{\}\|\.\*\?\(\)\$\^\\])/g,'\\$1');
  }

  searchString="("+searchString+")(?![\\s\\S]*"+searchString+")";
  if (sr$mc.checked)
    var re=new RegExp(searchString);
  else
    var re=new RegExp(searchString,"i");

  var res = re.exec (sr$t.value.substring(0,sr$t.selectionStart));
  if (!res) {
    var res = re.exec (sr$t.value)
  }

  if (res)
  {
    sr$t.selectionStart=res.index;
    sr$t.selectionEnd=res.index+res[1].length;
  }
  else sr$t.selectionStart=sr$t.selectionEnd;
  
  srSync();
}

function srNext()
{
  if (sr$s.value=='') {sr$t.focus(); return }

  if (sr$re.checked) {
    var searchString = sr$s.value;
  } else {
    searchString=sr$s.value.replace(/([\[\]\{\}\|\.\*\?\(\)\$\^\\])/g,'\\$1');
  }

  if (sr$mc.checked)
    var re=new RegExp(searchString,"g");
  else
    var re=new RegExp(searchString,"gi");

  re.lastIndex=sr$t.selectionEnd;
  var res = re.exec (sr$t.value)
  if (!res) {
    re.lastIndex=0;
    var res = re.exec (sr$t.value)
  }

  if (res)
  {
    sr$t.selectionStart=res.index;
    sr$t.selectionEnd=res.index+res[0].length;
  }
  else sr$t.selectionStart=sr$t.selectionEnd;
  srSync();
}

function srReplace()
{

  var sels=sr$t.selectionStart;
  var sele=sr$t.selectionEnd;
  var selr=sr$t.value.length-sele;

  if (sr$s.value=='' || sels==sele) {sr$t.focus(); return }

  if (sr$re.checked) {
    var searchString = sr$s.value;
    var replaceString = sr$r.value;

  } else {
    searchString=sr$s.value.replace(/([\[\]\{\}\|\.\*\?\(\)\$\^\\])/g,'\\$1');
    replaceString=sr$r.value.replace(/([\$\\])/g,'\\$1');
  }

  if (sr$mc.checked)
    var re=new RegExp(searchString,"g");
  else
    var re=new RegExp(searchString,"gi");

  re.lastIndex=sels;
  var res = re.exec (sr$t.value);
  var $$=0;
  if (res && res.index==sels && res[0].length==sele-sels)
  {
    if (sr$re.checked) {
      replaceString=replaceString.replace(/\\\\/g,'&backslash;').replace(/\\\$/g,'&dollar;')
      var replaceBits=(" "+replaceString).split(/(?=\$\d)/);
      replaceString=replaceBits[0].substring(1);
      for (var i=1; i<replaceBits.length; i++)
      {
        $$=replaceBits[i][1]-'0';
        if ($$<res.length)
           replaceString += res[$$] + replaceBits[i].substring(2)
        else
           replaceString += replaceBits[i];
     }
     replaceString=replaceString.replace (/\\n/,"\n").replace (/&backslash;/g,"\\").replace
                                         (/&dollar;/g,"\$")

    }
     sr$t.value= sr$t.value.substring(0,sels) + replaceString + sr$t.value.substring(sele);
  }

  sr$t.selectionStart=sels;
  sr$t.selectionEnd=sr$t.value.length-selr;
  srSync();
}


function srReplaceall()
{
  if (!sr$s.value) {sr$t.focus(); return }

  var sels=sr$t.selectionStart;
  var sele=sr$t.selectionEnd;
  var selr=sr$t.value.length-sele;

  var reps;

  if (sr$re.checked) {
    var searchString = sr$s.value;
    var replaceString = sr$r.value.replace(/\\\\/,'&backslash;').replace(/\\n/,'\n').replace(/&backslash;/,"\\");
  } else {
    searchString=sr$s.value.replace(/([\[\]\{\}\|\.\*\?\(\)\$\^\\])/g,'\\$1');
    replaceString=sr$r.value.replace(/([\$\\])/g,'\\$1');
  }

  if (sele>sels)
    reps=sr$t.value.substring(sels,sele);
  else
    reps=sr$t.value;
 
  if (sr$mc.checked)
    var re=new RegExp(searchString,"g");
  else
    var re=new RegExp(searchString,"gi");
  
  var replaceCounter=0;

  var replaceFunc=function(){replaceCounter++;return replaceString};

  reps=reps.replace(re,replaceFunc);

  if (sele>sels)
    sr$t.value = sr$t.value.substring(0,sels) + reps + sr$t.value.substring(sele);
  else
    sr$t.value = reps;

  sr$t.selectionStart=sels;
  sr$t.selectionEnd=sele>sels ? sr$t.value.length-selr : sels;
  window.status = replaceCounter+" ocurrences of " + searchString + " replaced.";
  srSync();
}

function srToggleCase()
{
  var sels=sr$t.selectionStart;
  var sele=sr$t.selectionEnd;
  var selr=sr$t.value.length-sele;
  var selt=sr$t.value.substring(sels,sele);

  if (sele>sels)
  {
    if (selt==selt.toUpperCase())
      selt=selt.toLowerCase()
    else if (selt==selt.toLowerCase() && sele-sels>1)
      selt=selt.substring(0,1).toUpperCase()+selt.substring(1).toLowerCase()
    else
      selt=selt.toUpperCase();

    sr$t.value = sr$t.value.substring(0,sels) + selt + sr$t.value.substring(sele);
    sr$t.selectionStart=sels;
    sr$t.selectionEnd=sele>sels ? sr$t.value.length-selr : sels;
  }
  srSync();
}


function srSync()
{
    var i;
    var allLines=0;
    var lineNo=0;
    var w=sr$t.cols-5;

    var dummy=sr$t.value.split("\n");
    for (i=0;i<dummy.length;i++){allLines+=Math.ceil(dummy[i].length/w)}

    var dummy=sr$t.value.substring(0,sr$t.selectionStart).split("\n");
    for (i=0;i<dummy.length;i++){lineNo+=Math.ceil(dummy[i].length/w)}

//    alert (w+" "+lineNo+"/"+allLines);

    sr$t.scrollTop=sr$t.scrollHeight*(lineNo-10)/allLines;
    sr$t.focus();
}


function srInit()
{

  if($e('wpTextbox1')) {
    
var srBoxCode ='<div id="srForm"><table id="srBox" cellpadding="0" cellspacing="2">'
           +'<tr><td valign="bottom"><small><span style="color:#000000;">search for:</span></small><br/>'
           +'<input type="text" id="srSearch" accesskey="F" tabindex="8"'
           +'onkeypress="event.which == 13 && srNext()"; value=""/></td>'
           +'<td valign="bottom"><small><span style="color:#000000;">replace with:</span></small><br/><input type="text" id="srReplace" accesskey="G" tabindex="9"'
           +'onkeypress="event.which == 13 && srNext()"; value=""/></td>'
           +'<td valign="top">'
           +'<input type="checkbox" id="srCase" onclick="sr$t.focus()" tabindex="10"/><small><span style="color:#000000;">match case</span</small>'
           +'<input type="checkbox" id="srRegexp" onclick="sr$t.focus()" tabindex="11"/><small><span style="color:#000000;">use regexp</span></small><br/> '
           +'<a href="javascript:srBack()" onmouseover="sr$t.focus()" title="find previous match [alt-2]" accesskey="2">&lt;</a>&nbsp;'
           +'<a href="javascript:srNext()" onmouseover="sr$t.focus()" title="find next match [alt-3]" accesskey="3">find&nbsp;&nbsp;&gt;</a>&emsp;'
           +'<a href="javascript:srReplace();srBack()" onmouseover="sr$t.focus()" title="replace and find previous match [alt-4]" accesskey="4">&lt;</a>&nbsp;'
           +'<a href="javascript:srReplace()" onmouseover="sr$t.focus()" title="replace this match">replace</a>&nbsp;'
           +'<a href="javascript:srReplace();srNext()" onmouseover="sr$t.focus()" title="replace and find next match [alt-5]" accesskey="5">&gt;</a>&emsp;'
           +'<a href="javascript:srReplaceall()" onmouseover="sr$t.focus()" title="replace all matches [alt-7]" accesskey="7">replace&nbsp;all</a>&emsp;'
           +'</td></tr></table></div>'

    var ep=$e('searchInput');
    ep.accessKey='none';

    sr$t=document.editform.wpTextbox1;
    sr$w=sr$t.style.width;

    var sr=document.createElement('div');
    sr.innerHTML=srBoxCode;

    var im=document.createElement('span');
    im.innerHTML='<a id="SearchIcon" href="javascript:srShowHide()"><img style="cursor: pointer;" title="Search/Replace" alt="Search/Replace" src="http://upload.wikimedia.org/wikipedia/en/1/12/Button_find.png" border="0" height="22" width="23"></a><a href="javascript:srToggleCase()"><img style="cursor: pointer;" title="Toggle case" alt="Toggle case" src="http://upload.wikimedia.org/wikipedia/en/1/12/Button_case.png" border="0" height="22" width="23"></a>';

    var ep=$e('toolbar');
    if (ep)
    {
      ep.appendChild(im)
    }
    else
    {
      var ep=$e('editform');
      ep.parentNode.insertBefore(im,ep);
    } 

    sr$i=$e('SearchIcon');
    sr$i.accessKey="F";
    sr.firstChild.style.display='none';


    var ep=$e('editform');
    ep.parentNode.insertBefore(sr,ep);

    sr$f=$e('srForm');
    sr$s=$e('srSearch');
    sr$r=$e('srReplace');
    sr$re=$e('srRegexp');
    sr$mc=$e('srCase');

  }
}

function srShowHide()
{
  if (sr$f.style.display=='none')
  {
    sr$f.style.display='block';
    sr$i.accessKey="none";
    sr$t.style.width='auto';
    sr$s.focus();
  }
  else
  {
    sr$f.style.display='none';
    sr$t.style.width=sr$w;
    sr$i.accessKey="F";
  }
}


document.write('<link rel="stylesheet" type="text/css" href="'  
             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/SearchBox.css'
             + '&action=raw&ctype=text/css&dontcountme=s">');

addOnloadHook(srInit);
//</nowiki></pre>

// <pre><nowiki>

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

// Admin warning tools START
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice of All/Adminwarnings/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
// Admin warning tools END

//Google tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Google/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//UTC clock
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/UTCclock.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//Admin protection tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Protection/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//---------------------------------------------------------------

 //<nowiki> AfD/PfD/Copyvio and tagging tabs
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/Deletion/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//</nowiki>[[Category:VoA scripted users|{{PAGENAME}}]]

//END
// ============= test-n.js ==============
function tnaddlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

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

  var li = document.createElement('li');
  li.appendChild(na);
  return li;
}
//---------------------------------------------------------------
function add_link2(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

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

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

//---------------------------------------------------------------
//Toolbox links
function changelinks() {
/*
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'my Talk page';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Change Preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Check my Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = 'My Contributions';
    document.getElementById('pt-logout').firstChild.innerHTML = 'Log out';
*/
}
function addtoolboxlinks() {
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', '');
    addlilink(tb, '/wiki/Special:Log/newusers', 'New users', '');
    addlilink(tb, '/wiki/Category:Candidates_for_speedy_deletion', 'Speedy deletions', '');
    addlilink(tb, '/wiki/Wikipedia:Administrator_intervention_against_vandalism', 'Vandalism', '');
    addlilink(tb, '/wiki/WP:RfPP', 'Protection requests', '');
    addlilink(tb, '/wiki/WP:PP', 'Protected pages', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard', 'Noticeboard', '');
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard/3RR', '3RR violations', '');
}
//END

//Auto AFD Lister--------------
// This needs to change depending on skin used. 
function add_link(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

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

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

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

  return target;
}

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

  var target = document.editform.action;
  target = document.title.split('Editing ')[1].split(' - ')[0];

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

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=vfdsub&faketarget=' + target,
              'Afd ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
  window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=vfdlist&faketarget=' + pagename,
              'AfdLog ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}

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

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

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

//AFD Closer----------------
//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]

function afdaddlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

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

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

function result()
{
  var close = prompt("Result of debate?")
  var f = document.editform, t = f.wpTextbox1;
  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 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 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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}

function 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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}

function 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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}

function 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 = "{{subst:" + "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 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 = "{{subst:" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
}

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

  // Only add for pages with the right string somewhere in the title 
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      tabs.appendChild(afdaddlilink('javascript:result()',"close"));
      tabs.appendChild(afdaddlilink('javascript:relist()',"relist"));
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      tabs.appendChild(afdaddlilink('javascript:keep()',"K"));
      tabs.appendChild(afdaddlilink('javascript:no_consensus()',"NC"));
      tabs.appendChild(afdaddlilink('javascript:redirect()',"R"));
      tabs.appendChild(afdaddlilink('javascript:merge()',"M"));
      if(document.getElementById('ca-delete'))
      {
        document.getElementById('ca-delete').firstChild.innerHTML = '[d]';
      }  
      if(document.getElementById('ca-move'))
      {
      document.getElementById('ca-move').firstChild.innerHTML = '[m]';
      } 
      if(document.getElementById('ca-watch'))
      {
      document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
       }  
      if(document.getElementById('ca-unwatch'))
      {
      document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
      }
    }
}

//end AfD closing script

// =-=-=- HELPER FUNCTIONS -=-=-=

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];
        }
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

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

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

function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", or "p-navigation".
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //* name is what will appear as the name of the button.
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //* key is the char you want for the accesskey. Optional.
    //* after is the id of the button you want to follow this one. Optional.
    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;
}
////////////////////////////////////////////////////////////////

// ======== USER TABS =======
 addOnloadHook(function() {
   if (document.title.search("/") != -1 || document.title.search("- History -") != -1) { //no subpages or history
      return;
   }
   if (document.title.indexOf("User:") == 0 || document.title.indexOf("User talk:") == 0) {
      username_a = document.URL.match(/:.*:(.*)/);
      username=username_a[1];
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "blocks", "ca-blog", "block log", "");
      addTab("http://tools.wikimedia.de/~essjay/edit_count/Count.php?username=" + username, "count", "ca-kate", "user info", "");
   }
 });

// ============= Purge ==============
function addPurge()
{
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    if(!document.getElementById) return;
    var x = document.getElementById('ca-history');
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    if(!x) return;
    if(x.children) x = x.children[0];
    else x = x.childNodes[0];
    addlilink(tabs, x.href.replace(/=history/, "=purge"), 'purge', 'ca-purge');
}

// ============= test-n.js ==============
function tnaddlilink(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);

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

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

function testn(number)
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]])" + article + "====" + "\n" + "{{subst:" + "test" + number + "}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " test" + number;
}

function warningn()
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]])" + varticle + "====" + "\n" + "{{subst:" + "bv" + "}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " bv";
}

function revertsn()
{
  var IPnoteR = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnoteR = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning, but aviod making any [[Wikipedia:revert|reverts]] within 24 hours of this warning in order to avoid any confusion.'' ";}
  var article = prompt("Enter the page name where the 3RR violation occured:")
  articleh = article.replace(/ /g, '_');
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding reversions" + "[http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history] " + "made on [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) to " + "[[" + article + "]]" + "====" + "\n" + "{{subst:" + "3rr" + "}} " + IPnoteR + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " 3rr";
}

function finalwn()
{
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += ":{{subst:" + "test4" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " final warning";
}

function blockn()
{
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += ":{{subst:" + "test5" + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " temporary block";
}

function rrblockn()
{
  username_a = document.URL.match(/:.*:(.*)/);
  username=username_a[1];
  var article = prompt("Enter the page name where the 3RR violation occured:");
  articleh = article.replace(/ /g, '_');
  var well = prompt("Was the user already warned for these reverts (*y* or *n*)?")
  var time = prompt("Enter the duration of the block (in hours)")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    {t.value += '\r';}
  t.value += '<div style="background-color: #f9f9f9; border: 1px solid red; padding: 3px;">' + '\n';
  if (well == 'y' || well == 'yes') {
  t.value += ":{{subst:" + "3rr3" + "}} The duration of the [http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username + " block] is " + time + " hours. [" + article + " Here] are the reverts in question. ~" + "~" + "~" + "~" + "</div>";}
  else if (well == 'n' || well == 'no') {
  t.value += "====" + "Regarding reversions" + "[http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history] " + "made on [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]]) to " + "[[" + article + "]]" + "====" + "\n" + "{{subst:" + "3rr3" + "}} The duration of the [http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username + " block] is " + time + " hours. ~" + "~" + "~" + "~" + "</div>";}
  else 
  {
  prompt("Error, enter *y* or *n*.");
  return;
  }
  f.wpSummary.value = "User notice:" + " temporary 3RR block";
}

function testbl()
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]])" + varticle + "====" + "\n" + "{{subst:" + "test2a}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " test2a";
}

function spam()
{
  var IPnote = '';
  if (document.title.split(' - ')[0].split('.').length == 4)
  {IPnote = "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|unconstructive]] edits.'' ";}
  var varticle = '';
  if (location.href.indexOf('&vanarticle=') != -1)
  {varticle = ' to [[' + unescape(location.href.split('&vanarticle=')[1]) + ']]';}
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during [[{{subst:CURRENTMONTHNAME}} {{subst:CURRENTDAY}}]] [[{{subst:CURRENTYEAR}}]] ([[UTC]])" + varticle + "====" + "\n" + "{{subst:" + "spam2a}} " + IPnote + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " spam2a";
}

function rrwarn()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="*The user has now been warned per [[WP:3RR|3RR]]. " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Response: user warned";
}

function rrblock()
{
  var number = prompt("User blocked for how many hours?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="*I have blocked the user for " + number + " hours per [[WP:3RR]]. " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Response: user blocked";
}

function rrnoblock()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="*The user has not yet violated [[WP:3RR]] because there are not yet four reverts over the ''same'' content in 24 hours ([[UTC]]). However, I have warned the user for nearly breaching [[WP:3RR]]. " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Response: user warned";
}

function prod()
{
  document.editform.wpTextbox1.value = '{{subst:Prod' + '}}\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'This page has been proposed for deletion and will be deleted in 5 days if no one objects.';
}

//Change move tab name
function changemovetab()
{/*
if (document.title.indexOf("Talk:") == -1 && document.title.indexOf("talk:") == -1 && document.title.indexOf("User:") == -1 && document.title.indexOf("MediaWiki:") == -1 && document.title.indexOf("Image:") == -1 && document.title.indexOf("Wikipedia:") == -1 && document.title.indexOf("Template:") == -1 && document.title.indexOf("Portal:") == -1 && document.title.indexOf("Help:") == -1 && document.title.indexOf("Main Page") == -1 && document.title.indexOf("Category:") == -1)
  {
  if(document.getElementById('ca-move'))
  {document.getElementById('ca-move').firstChild.innerHTML = 'Rename';}
  if(document.getElementById('ca-history'))
  {document.getElementById('ca-history').firstChild.innerHTML = 'Revisions';}
  }
if (document.title.split(' - ')[0].split(".js")[1] != undefined)
  {
  if (document.title.split(' - ')[0].split(".js")[1] != undefined)
     {
      if(document.getElementById('ca-nstab-main'))
      {
      document.getElementById('ca-nstab-main').firstChild.innerHTML = 'Javascript';
      }  
      else if(document.getElementById('ca-nstab-user'))
      {
      document.getElementById('ca-nstab-user').firstChild.innerHTML = 'User JS';
      } 
      else if(document.getElementById('ca-nstab-mediawiki'))
      {
      document.getElementById('ca-nstab-mediawiki').firstChild.innerHTML = 'MediaWiki JS';
      }  
    }
  }
*/}
//END

//more tabs
function add_testn_tabs()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
if (location.href.indexOf("&action=history") != -1)
  {
  if(document.getElementById('ca-edit'))
  {document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';}
  }
if (document.title.indexOf("") != -1)
{
if (document.title.indexOf("Editing ") != -1)
{
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      tabs.appendChild(tnaddlilink('javascript:revertsn()',"rr"));
      tabs.appendChild(tnaddlilink('javascript:warningn()',"v"));
      tabs.appendChild(tnaddlilink('javascript:testbl()',"b"));
      tabs.appendChild(tnaddlilink('javascript:spam()',"s"));
      tabs.appendChild(tnaddlilink('javascript:finalwn()',"fw"));
      tabs.appendChild(tnaddlilink('javascript:rrblockn()',"rrb"));
      tabs.appendChild(tnaddlilink('javascript:blockn()',"vb"));
      if(document.getElementById('ca-delete'))
      {
        document.getElementById('ca-delete').firstChild.innerHTML = '[d]';
      }  
      if(document.getElementById('ca-move'))
      {
      document.getElementById('ca-move').firstChild.innerHTML = '[m]';
      }  
      if(document.getElementById('ca-watch'))
      {
      document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
       }  
      if(document.getElementById('ca-unwatch'))
      {
      document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
    }
  else if (document.title.indexOf("Editing User:") != -1)
    {  
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'Protection (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'Protection (on)';
      }
    }
  else if (document.title.indexOf("Editing Wikipedia:Requests for page protection (section)") != -1)
    {
    if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-delete'))
      {
        document.getElementById('ca-delete').firstChild.innerHTML = '[d]';
      }  
      if(document.getElementById('ca-move'))
      {
      document.getElementById('ca-move').firstChild.innerHTML = '[m]';
      } 
      if(document.getElementById('ca-watch'))
      {
      document.getElementById('ca-watch').firstChild.innerHTML = '[w]';
       }  
      if(document.getElementById('ca-unwatch'))
      {
      document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
    }
  else if (document.title.indexOf("Editing Wikipedia:Administrators' noticeboard/3RR (section)") != -1)
    {
    tabs.appendChild(tnaddlilink('javascript:rrwarn()',"a|wn"));
    tabs.appendChild(tnaddlilink('javascript:rrblock()',"a|bl"));
    tabs.appendChild(tnaddlilink('javascript:rrnoblock()',"r|cl"));
    if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
    if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
    }
 else if(document.title.indexOf("Wikipedia:") != -1)
 {
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
   }
//This line removes a minor glitch [[Category:Wikipedia administrators who use VoA script]]
 else if(document.title.indexOf("Editing Help:Contents/Editing Wikipedia") != -1)
   {
      autocopyvio();
      tabs.appendChild(tnaddlilink('javascript:prod()',"pfd"));
      add_link('javascript:vfd()', 'Afd');
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
   }
 else if(document.title.indexOf("Help:Contents/Editing Wikipedia") != -1)
 {
 lastdiff()
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'Protection (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'Protection (on)';
      }
   }
 else if(document.title.indexOf("Editing Talk") != -1)
 {
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
   }
 else if(document.title.indexOf("Editing Wikipedia talk") != -1)
 {
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
   }
  else
   {
      autocopyvio();   
      tabs.appendChild(tnaddlilink('javascript:prod()',"pfd")); 
      add_link('javascript:vfd()', 'Afd');
      if(document.getElementById('ca-talk'))
      {
        document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)';
      }
      if(document.getElementById('ca-edit'))
      {
        document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
      }
   }
}
 else if (document.title.indexOf("User:") != -1)
 {
 lastdiff()
 if(document.getElementById('ca-talk'))
      {
     document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
      if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'Protection (off)';
      }
      if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'Protection (on)';
      }
 }
 else if (document.title.indexOf("User talk:") != -1)
 {
 if(document.getElementById('ca-history'))
      {
      lastdiff();
      }
 if(document.getElementById('ca-talk'))
      {
     document.getElementById('ca-talk').firstChild.innerHTML = 'Talk';
      }
 if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'Protection (off)';
      }
 if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'Protection (on)';
      }
 }
 else
 {
 if(document.getElementById('ca-history'))
      {
      lastdiff();
      }
 if(document.getElementById('ca-protect'))
      {
        document.getElementById('ca-protect').firstChild.innerHTML = 'Protection (off)';
      }
 if(document.getElementById('ca-unprotect'))
      {
        document.getElementById('ca-unprotect').firstChild.innerHTML = 'Protection (on)';
      }
   }
}
}

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

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

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

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia:Copyright_problems/' + datestring + '&action=edit&fakeaction=copyviolist&faketarget=' + pagename,
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}

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

      if (action == 'copyviolist')
        {
//          var index = document.editform.wpTextbox1.value.lastIndexOf("\n==Footer==");
/*            if (index == -1) 
          {
            window.alert("Couldn't find footer\n\n");
          } 
          else
          { */
//            var firsthalf = document.editform.wpTextbox1.value.substr(0,index);
//            var secondhalf = document.editform.wpTextbox1.value.substr(index);
            document.editform.wpTextbox1.value += '*[[' + target + ']] <span class="plainlinks">([http://en.wikipedia.org/{{localurl:' + target + '|action=history}} history] &middot; [http://en.wikipedia.org/{{localurl:' + target + '|diff=0}} last edit])</span>' + ' from [' + '] ~' + '~~' + '~';
            document.editform.wpSummary.value = 'Copyvio ' + '[[' + target + ']]';
          }
//        }
      else
        add_link2('javascript:copyvio()', '(cv)');
    }
}

//Purge tab
function addpurgel()
{
if (document.title.indexOf("Editing ") != -1)
{
return;
}
else
{
  if (document.title.indexOf("Wikipedia:") != -1)
   {
   if (location.href.indexOf("&action=history") == -1)
   {addPurge();}
   }
  if (document.title.indexOf("User:") != -1)
   {
addPurge();
   }
  if (document.title.indexOf("Category:") != -1)
   {
addPurge();
   }
}
}
//END
//************

//************
//LAST DIFF TAB
function lastdiff() 
    {
    if (document.title.indexOf("Editing ") != -1)
    {return;}
    z=document.getElementById("content").childNodes;
    for (var n=0;n<z.length;n++) { 
      if (z[n].className=="firstHeading") 
      {
  var pname=document.title.split(' - ')[0].replace(/&/g,'%26').replace(/\\+/g, '%2B');
      }
    }
    var l=addTab("http://en.wikipedia.org/w/index.php?title=" + pname + "&diff=cur&oldid=prev", 'last', '');
    l.lastChild.title="Show most recent diff";
}

// This will add an [edit top] link at the top of all pages except preview pages
function addtoplink()
{
var undefined;
var edittop = '<span style="color:black;">[</span>edit top<span style="color:black;">]</span>';
  // if this is preview page or generated page, stop
  if(document.getElementById("wikiPreview") || window.location.href.indexOf("w/index.php?title=Special:") != -1) return;
  if(document.title.indexOf("Main Page") != -1) return;

  // get the page title
  var pageTitle = document.title.split(" - ")[0].replace(" ", "_"); 

  // create div and set innerHTML to link
  var divContainer = document.createElement("div");
  divContainer.innerHTML = '<div class="editsection" style="float:right;margin-left:5px;margin-right:35px;margin-top:3px;"><a href="/w/index.php?title='+pageTitle+'&action=edit&section=0" title="'+document.title.split(" - ")[0]+'">' + edittop + '</a></div>';

  // insert divContainer into the DOM before the h1
if (document.getElementById("content") !=undefined) {
  document.getElementById("content").insertBefore(divContainer, document.getElementsByTagName("h1")[0]);}
}
//END

//************
//MAIN
//************

addOnloadHook(Mainfast)
function Mainfast() 
{
    add_testn_tabs();
    changemovetab();
    addpurgel();
    changelinks();
    addtoolboxlinks();
}

window.onload = Main;
function Main() 
{
    add_afd_tabs();
    addtoplink();
    //LivePreviewInstall();
    if(addSinceTab)
    {addSinceTab();}
}
//END
//************

//
Mvaluejsadmin = 'DMalak1';
Rvaluejsadmin = 'ERollenH1';
//
//************
//Slow load tools
//History tools
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Voice_of_All/History/monobook.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END
//New user log 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>');
//END
//************

//Interiot's javascript edit counter
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
  document.write('<script type="text/javascript" src="' 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }

//************
//Lupin's tools
//************
popupOnEditSelection = 'cursor';

//Filter changes live [[Category:Wikipedia administrators who use VoA script]]
//[[User:Lupin/recent2.js]] - please include this line
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

//[[User:Lupin/popupsdev.js]] - please include this line 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');

popupShortcutKeys=true; // optional: enable keyboard shortcuts
popupAdminLinks=true;   // optional: enable admin links [[Category:Wikipedia administrators who use VoA script]]
popupSubpopups=false;
popupStructure='shortmenus';
//END
//************

//Jude's autodeleter
addOnloadHook(function (){
if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
});	
function queryString(p) {
var re = RegExp('[&?]' + p + '=([^&]*)');
var matches;
if (matches = re.exec(document.location)) {
	try { 
		return decodeURI(matches[1]);
	} catch (e) {
	}
	}
return null;
};
//END

//</nowiki></pre>
//[[Category:Wikipedia administrators who use VoA script]]