User:Veinor/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.

function checkDb() {
  if (document.getElementById("wpTextbox1") != null) {
  if (document.getElementById("wpTextbox1").value.match(/\{\{((db-[^{]+)|deletedpage)\}\}/) != null && document.URL.match(/Tagged%20for%20speedy%20deletion/) != null) {
     alert("Page already has CSD tag.");
     history.back();
  }
}
}
addOnloadHook(checkDb);

//////////////////////////////////////////
function winc(s) {
    s = s.replace(/^\[\[/, '').replace(/\]\]$/, '');
    document.write('<script type="text/javascript" src="'
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}

winc('[[User:Veinor/mygodmode.js]]');         // Rollback
winc('[[User:Voice of All/Approvals.js]]');      // VoA EP:BAG tool
winc('[[User:Betacommand/Spam.js]]');      // Blog removal
winc('[[User:Veinor/GeorgeMoney.js]]');      // GeorgeMoney
winc('[[User:Betacommand/Sandbox.js]]');      // js sandbox
winc('[[User:Quarl/util.js]]');               // Utility functions
winc('[[User:Quarl/wikipage.js]]');           // WikiPage class
winc('[[User:Quarl/wikiedit.js]]');           // WikiEditor
winc('[[User:Quarl/diff.js]]');               // WikiEditor
winc('[[User:Quarl/cookie.js]]');             // cookie helpers
winc('[[User:Quarl/shortcuts.js]]');          // Shortcuts class

winc('[[User:Veinor/Personaltoolbox.js]]');  // Personal toolbox
winc('[[User:Cactus.man/Scripts/ChangeTitles.js]]');     // New personal menu & tab titles winc('[[User:Cactus.man/Scripts/Tabs.js]]');             // Additional tabs for editing pages
winc('[[User:Veinor/Moretabs.js]]');         // Additional tabs for user & project pages 
winc('[[User:Cactus.man/Scripts/PurgeTab.js]]');         // Add a purge tab to pages
//winc('[[User:Cactus.man/Scripts/FixDiffWidth.js]]');     // Fix diff widths
winc('[[User:Cactus.man/Scripts/Time.js]]');             // Add date and time to the personal menu
winc('[[User:Cactus.man/Scripts/ExtraEditButtons.js]]'); // Additional edit buttons





//////////////////////////////////////////
function addSinceTab() {
    if (window.location.href.indexOf("&action=history&gotosince=true")!=-1) {
       do_since_I_last_edited()
    }
    else if (!/wiki\/Special:|w\/index.php?title=Special:/.test(window.location.href)) {
       var thetitle=document.title.slice(0, String(document.title).indexOf(" - "));
       var l=addLink('p-cactions', "/w/index.php?title="+thetitle+"&action=history&gotosince=true", 'since', 'ca-since', 'View diff from last edit by me', '', 'ca-history');
       l.lastChild.title="Changes since I last edited";
    }
}
function do_since_I_last_edited() {
 var csub=document.getElementById("contentSub");
 var msg=document.createElement("p");
 msg.appendChild(document.createTextNode
 ("Parsing history... please wait..."));
 msg.className="error";
 csub.insertBefore(msg, csub.firstChild)

 var username=document.getElementById("pt-userpage").textContent;
 var hists=document.getElementById("pagehistory").childNodes;
 for (n=0;n<hists.length;n++) {
     if (hists[n].getElementsByTagName("span")[0].textContent==username) {
 document.location=hists[n].childNodes[1].href; 
 return;
     }
 }

 msg.replaceChild(document.createTextNode
  ("You have not edited this page! (recently)"),
  msg.firstChild);
}

addOnloadHook(addSinceTab);
//////////////////////////////////////////



//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>'); }
//

//<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>');
//</nowiki>

//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>');

//
function JSlauncher()
{
if (location.href.indexOf('&JScript=') != -1)
  {
  var target = location.href.split('&JScript=')[1];
  location.href = "javascript:" + target;
  }
}
//


//////////////////////////////
//Autosumbits
function jssubmit()
{
var form = document.getElementById('bodyContent');
l = form.getElementsByTagName('input');
for (var i = 0; i < l.length; i++)
      {
    if (l[i].name == 'wpMinoredit')
    {l[i].value = '1'; l[i].checked=true;}
      }
    var form = document.getElementById('bodyContent');
    l = form.getElementsByTagName('input');
for (var i = 0; i < l.length; i++)
      {
    if (l[i].name == 'wpMinoredit')
      {l[i].value = '1'; l[i].checked=true;}
      }
var form = document.getElementById('editform');
form.submit();
}
//////////////////////////////

// Add block buttons to the page
// ----------------------------------------------------------------------------- 
function AddBlockButtons() {
  var l, article = '', vandal;
  // Add 'block' links to a diff page
  l = document.getElementById('t-contributions');
  if (l) {
    clone = l.cloneNode(true);
    l.id = 't-blockuser';
    a = clone.getElementsByTagName('a')[0];
    a.href = a.href.replace(/Special:Contributions\//, 'Special:Blockip/');
    a.href = a.href.replace(/target=/, 'faketarget=');
    a.innerHTML = blocklink;
    l.parentNode.insertBefore(clone, l.nextSibling);
  }
}
 
document.write('<script type="text/javascript" src="http://countervandalism.org/index.php?title=CVU:GodMode/godmode.js&action=raw&ctype=text/javascript&dontcountme=s"></script>'); 
 
// include comfortable javascript editor by cacycle

// levels of undo (each level holds the whole text)
var undoBufferMax = 20;

// text and popup title of summary buttons
var summaryButtons = [
  ['Copyedit',  'Copyedit'],
  ['Linkfix',   'Linkfix'],
  ['Vandal',    'Reverting vandalism'],
  ['Format',    'Formatting source text'],
  ['Cap lists', 'Capitalizing (link) lists as per [[Wikipedia:List]] and [[Wikipedia:Manual_of_Style]]'] 
];

// background color of preview box
var previewBackground = '#ffffdd';

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

// Live Preview ([[User:Pilaf/Live Preview]], )
wpUserName   = 'Veinor'; // User name to display in signatures 
wpShowImages = true; // Enable downloading and displaying of images
document.write('<script type="text/javascript" src=" http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

// installs the editor and other tools after loading the page 
window.onload = Main;
function Main() {
  SetupEditor();
//  othertools();
}
 
 
// 
function tnbaddlilinkc(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_testn_tabsc()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Only add for pages with "Editing User talk:" somewhere in the title
  if (document.title.indexOf("User talk:") != -1)
    {
      tabs.appendChild(tnbaddlilinkc('javascript:testn(1)',"Test 1"));
      tabs.appendChild(tnbaddlilinkc('javascript:testn(2)',"Test 2"));
      tabs.appendChild(tnbaddlilinkc('javascript:testn(3)',"Test 3"));
      tabs.appendChild(tnbaddlilinkc('javascript:testn(4)',"Test 4"));
    }
}

addOnloadHook(add_testn_tabsc);

// Returns <li><a href="url">name</a></li>
function addlilinkt(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;
}

// Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&faketarget=username" is present.
function do_blockip_stuff()
{
  // Look for a &faketarget= for the username/ip
  var l = location.search.substring(1).split('&');
  var target = '';
  for (var i = 0; i < l.length; ++i)
    {
      var n = l[i].indexOf('=');
      if (l[i].substring(0, n) == 'faketarget')
 {
   target = l[i].substring(n + 1);
   break;
 }
    }

  if (target == '')
    return;

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

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


function add_unverified_tab()
{
//My Test
tabs.appendChild("javascript:unverified()", "unverified", "ca-unverified", "Tag as unverified", "");
}

function unverified() 
{
//document.forms[0].wpTextbox1.value = document.forms[0].wpTextbox1.value + "\n    erified}}";
//document.forms[0].wpSummary.value = "unverified";
//document.forms[0].submit();
//document.forms[0].wpMinoredit.checked = true;
}

// ======== 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].split('&')[0];
      addTab("http://en.wikipedia.org/wiki/Special:Contributions/" + username, "contrib", "ca-contrib", "contribs", "");
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=move&user=" + username, "page moves", "ca-pagemoves", "page moves", "");
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=" + username, "block log", "ca-blog", "blog", "");
      addTab("http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=" + username, "edit count", "ca-kate", "Edit Count", "");
   }
 });

// ==========logs link on toolbox =========
addOnloadHook(function () {

 // get page title
 var pagetitleRe=/[^:]*:\/\/en\.wikipedia\.org\/(wiki\/|w\/index\.php\?title=)([^&?#]*)/;
 ptitle = pagetitleRe.exec(decodeURI(location.href))[2].split('_').join(' ');
 
 // if this is a user, show the logs for the user rather than the page
 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) {
  // don't display link for special pages
  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");

});

// ============ replace within edit dialog ==============
function replace() {
    var s = prompt("Search regexp?");
    if(s) {
        var r = prompt("Replace regexp?");
        if(!r && r != '') return;
        var txt = document.editform.wpTextbox1;
        txt.value = txt.value.replace(new RegExp(s, "g"), r);
    }
}
/**/
  // AutoCopyvio - Adds copyright violation notice to article and adds entry to Copyright Problems page
  // Created by Bmicomp from modified AutoVFD(by Korath)
  
  function add_link2(url, name)
  {
    var na = document.createElement('a');
    na.setAttribute('href', url);
    na.appendChild(document.createTextNode(name));
  
    var li = document.createElement('li');
    li.appendChild(na);
  
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    tabs.appendChild(li);
  }
  
  function strip_namespace(target)
  {
    var colon = target.indexOf(':');
    if (colon != -1)
      {
        var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
        var ns = target.substring(0, colon);
        if (ns == '' || ns == 'Talk')
          return target.substring(colon + 1);
        else
          for (var i = 0; i < spaces.length; ++i)
            {
              if (ns == spaces[i]
                  || ns == spaces[i] + '_talk')
                return target.substring(colon + 1);
            }
      }
    return target;
  }
  
  function copyvio()
  {
    var website= prompt("What is the Website?");
    document.editform.wpTextbox1.value = '{' + '{' + 'copyvio|url= +website+ }}';
    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();
    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')
          {
              document.editform.wpTextbox1.value += '*[[' + target + ']] <span class="plainlinks">([http://en.wikipedia.org/{{localurl:' + target + '|action=history}} history] ยท [http://en.wikipedia.org/{{localurl:' + target + '|diff=0}} last edit])</span>' + ' from [' +website+ '] ~' + '~~' + '~';
              document.editform.wpSummary.value = 'Copyvio ' + '[[' + target + ']]';
          }
        else
          add_link2('javascript:copyvio()', 'copyvio');
      }
  }
  
  addOnloadHook(autocopyvio);
 /**/

//Please leave the following line
//user:Where/easy db
//Start db script
addOnloadHook(function() {
  if (document.title.indexOf("Editing ") != 0 && document.URL.search(/\?/) == -1)  {
     addTab("javascript:easyDb(0)", "db-", "ca-db0", "db-", "");
     //addTab("javascript:easyDb(1)", "db|", "ca-db0", "db|", "");

  }
});
function easyDb(n) {
  var db;
  if (n == 0) {db="db-";}
  if (n == 1) {db="db|";}
  var type = prompt("What is X in Template:" + db + "X ?");
  if (type == null || type == "") return;
 /* if (document.getElementById("delete") != null) {
    alert("Page already has a CSD tag.");
    return;
  } */
  var currlocation = document.URL;
  document.location = document.URL + "?action=edit&autoedit=s/^/\n{{" + db + type +  "}}\n/&autosummary=Tagged for speedy deletion";
   if (document.getElementById("noarticletext") != null) {
     alert("Page already deleted.");
     document.location = currlocation;
  } else {
     document.location = currlocation += "?action=edit&autoedit=s/^/\n{{" + db + type + "}}\n/&autosummary=Tagged for speedy deletion&autoclick=wpSave";
  }
}


//End db script
addOnloadHook(function() {
  if (document.title.indexOf("Editing ") != 0 && document.URL.search(/\?/) == -1)  {
     addTab("javascript:easyDb2(3)", "db-cat", "ca-db0", "db-Catempty", "");
  }
});

function easyDb2(n) {
  var db;
  if (n == 3) {db="db-catempty";}
  
  document.location = document.URL + "?action=edit&autoedit=s/^/\n{{" + db + "}}\n/&autosummary=Tagged for speedy deletion&autoclick=wpSave";
}
// 
function inc (file) {
  var lt = String.fromCharCode(60);
  var gt = String.fromCharCode(62);
  document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}

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

//<nowiki>
//---------------------------------------------------------------
//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
//---------------------------------------------------------------
//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
//---------------------------------------------------------------
// ============= 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

//---------------------------------------------------------------
//Monobooks
function monobkpg() 
{
if (location.href.split("monobook.js")[1] != undefined)
  {
      if(document.getElementById('ca-nstab-main'))
      {
      document.getElementById('ca-nstab-main').firstChild.innerHTML = 'monobook';
      }  
      else if(document.getElementById('ca-nstab-user'))
      {
      document.getElementById('ca-nstab-user').firstChild.innerHTML = 'monobook';
      } 
      else if(document.getElementById('ca-nstab-mediawiki'))
      {
      document.getElementById('ca-nstab-mediawiki').firstChild.innerHTML = 'monobook';
      }  
   }
}
//---------------------------------------------------------------


//---------------------------------------------------------------
//Toolbox links
function changelinks() {
    if(!document.getElementById) return;
    document.getElementById('pt-mytalk').firstChild.innerHTML = 'Talk';
    document.getElementById('pt-preferences').firstChild.innerHTML = 'Preferences';
    document.getElementById('pt-watchlist').firstChild.innerHTML = 'Watchlist';
    document.getElementById('pt-mycontris').firstChild.innerHTML = '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', '');
}
//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 = target.substring(target.indexOf('title=') + 6,
                            target.lastIndexOf('&action=submit'));

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

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia: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()',"Keep"));
      tabs.appendChild(afdaddlilink('javascript:no_consensus()',"No Consensus"));
      tabs.appendChild(afdaddlilink('javascript:redirect()',"Redirect"));
      tabs.appendChild(afdaddlilink('javascript:merge()',"Merge"));
      if(document.getElementById('ca-delete'))
      {
        document.getElementById('ca-delete').firstChild.innerHTML = 'Delete';
      }  
      if(document.getElementById('ca-move'))
      {
      document.getElementById('ca-move').firstChild.innerHTML = 'Move';
      } 
      if(document.getElementById('ca-watch'))
      {
      document.getElementById('ca-watch').firstChild.innerHTML = 'Watch';
       }  
      if(document.getElementById('ca-unwatch'))
      {
      document.getElementById('ca-unwatch').firstChild.innerHTML = 'UnWatch';
      }
    }
}

//end AfD closing script

// ======== 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].split('&')[0];
      addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User:" + username, "log", "ca-blog", "block log", "");
      addTab("http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?dbname=enwiki_p&user=" + username, "info", "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)
{
  if (document.title.indexOf('Editing ') == 0)
  {
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "test" + number + "-n|" + page + "}} ~" + "~" + "~" + "~";
  f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number;
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=testn(' + number + ')';
  }
}

function warningn()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during {{subst:CURRENTMONTH}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} ([[UTC]])" + "====" + " {{subst:" + "bv" + "}} " + "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|malicious]] edits.'' " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " bv";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=warningn()';
  }
}

function revertsn()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  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:CURRENTMONTH}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} ([[UTC]]) to " + "[[" + article + "]]" + "====" + " {{subst:" + "3rr" + "}} " + "''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.'' " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " 3rr";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=revertsn()';
  }
}

function finalwn()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  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";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=revertsn()';
  }
}

function blockn()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  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";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=revertsn()';
  }
}

function rrblockn()
{
 if (document.title.indexOf('Editing ') == 0)
  {
  username_a = document.URL.match(/:.*:(.*)/);
  username=username_a[1].split('&')[0];
  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 += '\n';
  if (well == 'y') 
      {
  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. ~" + "~" + "~" + "~";
  jssubmit();
      }
  else if (well == 'n') 
      {
  t.value += "====" + "Regarding reversions" + "[http://en.wikipedia.org/w/index.php?title=" + articleh + "&action=history] " + "made on {{subst:CURRENTMONTH}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} ([[UTC]]) to " + "[[" + article + "]]" + "====" + " {{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. ~" + "~" + "~" + "~";
  jssubmit();
      }
  else 
      {
  prompt("Error, enter *y* or *n*.");
  return;
      }
  f.wpSummary.value = "User notice:" + " temporary 3RR block";
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=rrblockn()';
  }
}

function warn()
{
 if (document.title.indexOf('Editing ') == 0)
  {
    var txt = document.editform.wpTextbox1;
var prompter = prompt("Which warning do you wish to issue?");
var msgtext = "{{subst:" + prompter + "}}~~~~";
var summary = "{{" + prompter + "}}";
    document.editform.wpSummary.value = summary;
    if(txt.value.length > 0) txt.value += '\n';
    txt.value += msgtext;
    document.editform.submit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=warn()';
  }
}

function testbl()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during {{subst:currentmonth}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} ([[UTC]])" + "====" + " {{subst:" + "test2a}} " + "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you did not make any [[Wikipedia:vandalism|malicious]] edits.'' " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " test2a";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=testbl()';
  }
}

function spam()
{
  if (document.title.indexOf('Editing ') == 0)
  {
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value +="====" + "Regarding edits made during {{subst:currentmonth}} {{subst:CURRENTDAY}} {{subst:CURRENTYEAR}} ([[UTC]])" + "====" + " {{subst:" + "spam2a}} " + "''If this is an [[IP address]], and it is shared by multiple users, ignore this warning if you were not the one who added [[Wikipedia:spam|spam]] links.'' " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "User notice:" + " spam2a";
  jssubmit();
  }
  else
  {
  var name =  document.title.split(' - ')[0];
  location.href = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=edit&JScript=spam()';
  }
}
////

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 = '{{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.';
}

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

if  (document.title.indexOf("") != -1)
{
if (document.title.indexOf("Editing ") != -1)
{
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      tabs.appendChild(tnbaddlilinkc('javascript:revertsn()',"3RR"));
      tabs.appendChild(tnbaddlilinkc('javascript:warningn()',"v"));
      tabs.appendChild(tnbaddlilinkc('javascript:testbl()',"b"));
      tabs.appendChild(tnbaddlilinkc('javascript:spam()',"s"));
      tabs.appendChild(tnbaddlilinkc('javascript:finalwn()',"fw"));
      tabs.appendChild(tnbaddlilinkc('javascript:rrblockn()',"rrb"));
      tabs.appendChild(tnbaddlilinkc('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(tnbaddlilinkc('javascript:rrwarn()',"a|wn"));
    tabs.appendChild(tnbaddlilinkc('javascript:rrblock()',"a|bl"));
    tabs.appendChild(tnbaddlilinkc('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:VoA scripted admins]]
 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()',"Prod For Deletion")); 
      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:") == 0)
 {
      tabs.appendChild(tnbaddlilinkc('javascript:revertsn()',"3RR Warning"));
      tabs.appendChild(tnbaddlilinkc('javascript:warningn()',"v"));
      tabs.appendChild(tnbaddlilinkc('javascript:testbl()',"b"));
      tabs.appendChild(tnbaddlilinkc('javascript:spam()',"s"));
      tabs.appendChild(tnbaddlilinkc('javascript:finalwn()',"fw"));
      tabs.appendChild(tnbaddlilinkc('javascript:rrblockn()',"rrb"));
      tabs.appendChild(tnbaddlilinkc('javascript:blockn()',"vb"));
 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)';
      }
   }
}
}

//************
//LAST DIFF TAB
function lastdiff() 
    {
    z=document.getElementById("content").childNodes;
    for (var n=0;n<z.length;n++) { 
      if (z[n].className=="firstHeading") {
        var pname=z[n].textContent;
      }
    }
    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
//************
//Editing options
//************
//Toolbar links
function InsertButtonsToToolBar()
{
 tooly = document.getElementById('toolbar');

 if (tooly != null) 
{
  StrikeTextButton = "<a href=\"javascript:insertTags('<s>','</s>','Insert text here');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png\" alt=\"Strike\" title=\"Strike-through text\"></a>";

LeftTexttButton = "<a href=\"javascript:insertTags('<div style=&quot;text-align: left; direction: ltr; margin-left: 1em;&quot;>\\n','\\n</div>','Left-aligned text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/e/ea/Button_align_left.png\" alt=\"Left-align\" title=\"Left-aligned text\"></a>";

  CenterTextButton = "<a href=\"javascript:insertTags('<div style=&quot;text-align: center;&quot;>','</div>','Centered text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/5/5f/Button_center.png\" alt=\"Centered\" title=\"Centered text\"></a>";

  TableButton = "<a href=\"javascript:insertTags('\\n{| border=&quot;1&quot; \\n|- \\n| 1 || 2\\n|- \\n| 3 || 4','\\n|}\\n','');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png\" alt=\"Table\" title=\"Insert table\"></a>";

  EenterButton = "<a href=\"javascript:insertTags('<br />','','');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png\" alt=\"Break\" title=\"Line break\"></a>";

  UpperTextButton = "<a href=\"javascript:insertTags('<sup>','</sup>','Superscript');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png\" alt=\"Superscript\" title=\"Superscript text\"></a>";

  LowerTextlButton = "<a href=\"javascript:insertTags('<sub>','</sub>','Subscript');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png\" alt=\"Subscript\" title=\"Subscript text\"></a>";

  SmallTextButton = "<a href=\"javascript:insertTags('<small>','</small>','Small text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png\" alt=\"Small\" title=\"Small text\"></a>";

  CommentButton = "<a href=\"javascript:insertTags('<!--','-->','Comment here');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png\" alt=\"Comment\" title=\"Insert hidden comment\"></a>";

  GalleryButton = "<a href=\"javascript:insertTags('\\n<gallery>\\n','\\n</gallery>','Image:FileName.jpg|Caption1\\Image:FileName2.jpg|Caption2');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png\" alt=\"Gallery\" title=\"Insert a picture gallery\"></a>";

  SecondaryHeadlineButton = "<a href=\"javascript:insertTags('\\n===','===','Secondary headline');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/e/e9/Button_headline2.png\" alt=\"2nd header\" title=\"Insert secondary headline\"></a>";

ShiftingButton = "<a href=\"javascript:insertTags(':','',':');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/8/8e/Button_shifting.png\" alt=\"Tab\" title=\"Insert tab(s)\"></a>";

  BlockQuoteButton = "<a href=\"javascript:insertTags('<blockquote style=&quot;border: 1px solid blue; padding: 2em;&quot;>\\n','\\n</blockquote>','Block quote');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png\" alt=\"Block quote\" title=\"Insert block of quoted text\"></a>";

  FontColorButton = "<a href=\"javascript:insertTags('<span style=&quot;color: ColorName&quot;>','</span>','Span of text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/1/1e/Button_font_color.png\" alt=\"Color\" title=\"Insert colored text\"></a>";

  CodeButton = "<a href=\"javascript:insertTags('<code>','</code>','Code');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/2/23/Button_code.png\" alt=\"Code\" title=\"Insert code\"></a>";

  SubLinkButton = "<a href=\"javascript:insertTags('[[Page#',']]','Sub_page');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/9/93/Button_sub_link.png\" alt=\"sub-page link\" title=\"Insert link to sub-page\"></a>";

  DefinitionListCodeButton = "<a href=\"javascript:insertTags('\\n; ',' : ','Insert text');\"><img src=\"http://upload.wikimedia.org/wikipedia/en/d/d3/Button_definition_list.png\" alt=\"Definition\" title=\"Insert definition list\"></a>";

 tooly.innerHTML = tooly.innerHTML + StrikeTextButton + LeftTexttButton + CenterTextButton + TableButton + EenterButton + UpperTextButton + LowerTextlButton + SmallTextButton + CommentButton + GalleryButton + SecondaryHeadlineButton + ShiftingButton + BlockQuoteButton + FontColorButton + CodeButton + SubLinkButton + DefinitionListCodeButton;
}
}
//END
//************

//************
//MAIN
addOnloadHook(Mainfast)
function Mainfast() 
{
    JSlauncher();
    add_testn_tabsb();
    add_afd_tabs();
    changelinks();
    addtoolboxlinks();
    monobkpg();
}

window.onload = Main;
function Main() 
{
    InsertButtonsToToolBar();
    addtoplink();
}
//END
//************


//************
//Lupin's tools
//************
// <nowiki>Filter changes live [[Category:VoA scripted admins]]
// [[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:VoA scripted admins]]
popupSubpopups=true;
popupFixDabs=true;
popupFixRedits=true;
//END
//************
//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

//</nowiki>[[Category:Wikipedians who use VoA script ]]


//</nowiki>VoA Revert functions

//<pre><nowiki>

////////////////////////////////////////////////////////////////

//Edit and "revert to" JS
//addOnloadHook(adddifflinks)
function adddifflinks()
{
var editlink = '<strong><span style="color:black;">[</span>edit this version<span style="color:black;">]</span></strong> ';
var rvname = ' <strong><span style="color:black;">[</span><span style="color:red;">restore this revision</span><span style="color:black;">]</span></strong><br>';
var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
if (location.href.indexOf('diff=') != -1 && location.href.indexOf('&oldid=') != -1)
  {
  var doctd = document.getElementById('bodyContent').getElementsByTagName('td');
  var good_user = doctd[0].getElementsByTagName('a')[2].innerHTML;
  var link = doctd[0].getElementsByTagName('a')[0].href.replace('&amp;','&') + "&action=edit";
  var rvlink = doctd[0].getElementsByTagName('a')[0].href.replace('&amp;','&') + "&action=edit&fakeaction=autorevert&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user);
    document.getElementById('bodyContent').getElementsByTagName('td')[0].innerHTML = '<a href="' + rvlink + '">' + rvname + '</a>' + document.getElementById('bodyContent').getElementsByTagName('td')[0].innerHTML;
   }
}
//END

//addOnloadHook(IEhistory_revert)
function IEhistory_revert()
{
if (location.href.indexOf('&action=history&limit=8&fakeaction=IEnormalrevert&user=') != -1)
  { 
  var found = 0;
  var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
  if (unescape(location.href.split('&byuser=')[1]) != user_name){alert('Invalid user match'); return;}
  var vandal = unescape(location.href.split('&fakeaction=IEnormalrevert&user=')[1].split('&byuser=')[0]);
  var l = document.getElementsByTagName('li');
  if (l[0].getElementsByTagName('a')[2].innerHTML != vandal)
  {alert('Could not rollback. Last contributor has changed.'); return;}
  for (i = 1; i < l.length; i++)
      {
     if (!l[i].getElementsByTagName('a')[3]){alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1); return;}
     if (l[i].getElementsByTagName('a')[3].innerHTML != vandal)
         {
     var good_user = l[i].getElementsByTagName('a')[3].innerHTML;
     var URL = l[i].getElementsByTagName('a')[2].href + "&action=edit&fakeaction=autorevert&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal);
     location.href = URL;
     found = 1;
     break;
         }
      }
   if (found == 0)
  {alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1);}
   }
if (location.href.indexOf('&action=history&limit=8&fakeaction=IErollback&vandal=') != -1)
  { 
  var found = 0;
  var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
  if (unescape(location.href.split('&byuser=')[1]) != user_name){alert('Invalid user match'); return;}
  var vandal = unescape(location.href.split('&fakeaction=IErollback&vandal=')[1].split('&byuser=')[0]);
  var l = document.getElementsByTagName('li');
  if (l[0].getElementsByTagName('a')[2].innerHTML != vandal)
  {alert('Could not rollback vandal. Last contributor has changed.'); return;}
  for (i = 1; i < l.length; i++)
      {
     if (!l[i].getElementsByTagName('a')[3]){alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1); return;}
     if (l[i].getElementsByTagName('a')[3].innerHTML != vandal)
         {
     var good_user = l[i].getElementsByTagName('a')[3].innerHTML;
     var URL = l[i].getElementsByTagName('a')[2].href + "&action=edit&fakeaction=autorevertvandal&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal);
     location.href = URL;
     found = 1;
     break;
         }
      }
   if (found == 0)
  {alert('Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 6 page edits, so you may want to look back further and use "restore".'); history.go(-1);}
   }
}
//END

function autosave()
{
user_name = escape(document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML);
if (location.href.indexOf("&fakeaction=autorevert&byuser=" + user_name) != -1 || location.href.indexOf("&fakeaction=autorevertvandal&byuser=" + user_name) != -1) 
    {
  if (location.href.indexOf('&revertfromuser') == -1 && location.href.indexOf('&fakeaction=autorevertvandal') == -1)
  { 
  var return_value = true; 
  if (return_value != true){history.go(-1); return;}
  }
  var good_user = unescape(location.href.split("&oldrvtouser=")[1].split('&revertfromuser=')[0]);
  var ID = location.href.split("&oldid=")[1].split("&action=edit")[0];
  form = document.getElementById('bodyContent');
  l = form.getElementsByTagName('input');
  for (i = 0; i < l.length; i++)
      {
    if (l[i].name == 'wpMinoredit')
      {l[i].value = '1'; l[i].checked=true;}
      }
if (location.href.indexOf('&fakeaction=autorevertvandal') != -1)
       { 
var artname = document.title.split('Editing ')[1].split(' - ')[0];
var vandal = unescape(location.href.split('&revertfromuser=')[1]);
document.editform.wpSummary.value += 'Reverted [[WP:VAND|vandalism]] by [[Special:contributions/' + vandal + '|' + vandal + ']] to last version by ' + good_user + '.';
var form = document.getElementById('editform');
window.open('http://en.wikipedia.org/w/index.php?title=User talk:' + vandal + '&action=edit' + '&action=edit&vanarticle=' + artname,
              'targetname',
    'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,width=1024,height=768');
form.submit();
        }
else if (location.href.indexOf('&revertfromuser=') != -1)
       { 
var vandal = unescape(location.href.split('&revertfromuser=')[1]);
document.editform.wpSummary.value += 'Reverted edits by [[Special:contributions/' + vandal + '|' + vandal + ']] to last version by ' + good_user + '.';
var form = document.getElementById('editform');
form.submit();
       }
else
       {
document.editform.wpSummary.value += 'Revert to revision ' + ID + ' by [[User:' + good_user + '|' + good_user + ']].';
var form = document.getElementById('editform');
form.submit();
       }
    }
}
//END

//Revert options
addOnloadHook(NArevertfunctions)
function NArevertfunctions()
{
//adddifflinks();
autosave();
}



// STATUS CHANGER
addOnloadHook(function (){
  var user = document.getElementById( 'pt-userpage' ).firstChild.firstChild.data;
  var subpage = "/Status";
  var scheme = "/StatusDiv";
  var linkprefix = "http://en.wikipedia.org/w/index.php?title=User:";
  var contribs = document.getElementById( 'pt-logout' );
  //Add the links
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=online", "[Online|", "pt-status-online", "Online", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=busy", "Busy|", "pt-status-busy", "I'm busy!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=away", "Away|", "pt-status-away", "I'm away!", "");
  addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=sleeping", "Sleeping|", "pt-status-sleeping", "I'm sleeping!", "");
 addlilink(contribs, linkprefix+user+subpage+"&action=edit&newstatus=hunting", "hunting]", "pt-status-online", "hunting", "");
  if (location.href.indexOf("User:"+user+subpage+"&action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
  //Get new status
  status = location.href.split("=");
  status = status[status.length-1];
  //Modify the form
  document.getElementById('wpTextbox1').value = "{{User:"+user+scheme+"|"+status+"}}";
  document.getElementById('wpSummary').value = "Status: "+status;
  document.getElementById('wpMinoredit').checked = 'checked';
  //Submit it!
  document.getElementById('editform').submit();
});
//END</nowiki></pre>


////////////////////////////
// Edit tools for the vandal whack-a-mole game
 // [[User:Kbh3rd/whackamole.js]] - please include this line
 //
 /*document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Kbh3rd/whackamole.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');*/

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;
 };

// Admin rollback tools [[Category:Wikipedia administrators who use VoA script|{{PAGENAME}}]]
/*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>');*/
//


//
addOnloadHook(Dfn_js_con)
function Dfn_js_con()
{
//moves
Mvaluejs_class = 'moves';
//edits
Rvaluejs_class = 'edit';
//uploads
Uvaluejs_class = 'image';
}
//
ta['ca-move'] = new Array('','Move this page');

function changeNewMessages() {
  var divs = document.getElementsByTagName('div');
  for (var i=0;i<divs.length; i++) {
    if (divs[i].className == "usermessage") {
     divs[i].innerHTML = 'You have <a href="/w/index.php?title=User_talk:Veinor&amp;redirect=no" title="User talk:Veinor">new spam</a> (<a href="/w/index.php?title=User_talk:Veinor&amp;diff=cur" title="User talk:Veinor">last vandalism</a>).';
    }
  }
}
addOnloadHook(changeNewMessages);

function inc (file) {
  var lt = String.fromCharCode(60);
  var gt = String.fromCharCode(62);
  document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&action=raw&ctype=text/javascript&dontcountme=s"'+gt+lt+'/script'+gt);
}

inc("User:Lightdarkness/aiv.js");