Jump to content

User:49TL/monobook/old/2.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 49TL (talk | contribs) at 16:24, 1 August 2006 (rv). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* <pre> */
////////////////////////////////////////////////////////////////////////////
// [[User:FireFox]]'s monobook.
// Most of it copied from some place or other and where it is, I've tried to give a source.
// If you want to copy any of it, I'd be flattered.
////////////////////////////////////////////////////////////////////////////
//<pre><nowiki>

/******************** Helper Functions (Needed) ********************/

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

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 addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}

// 

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

// Get's the URL version of the page title.
function get_tidy_title()
{
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  // cut everything up to "title=" from the start and everything past "&action=edit" from the end
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));

  return editlk;
}

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", "p-navigation", or "p-tb".
    //
    //* 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;
}
    
// 

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=move&user=" + username, "moves", "ca-pagemoves", "page moves", "");
     addTab("http://en.wikipedia.org/w/index.php?title=Special:Ipblocklist&action=unblock&ip=" + username, "un", "ca-unblock", "unblock", "");
     addTab("http://en.wikipedia.org/w/index.php?title=Special:Blockip&ip=" + username, "block", "ca-block", "block", "");
     addTab("http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A" + username, "log", "ca-blog", "block log", "");
  }
});

/************* afd Helper ************/
// see User:Jnothman/afd_helper

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

afdh_signature = '~~'+'~';
afdh_summaryprompt = true;
afdh_useicons = false;

afdh_shortcuts = Array();
afdh_shortcuts['d'] = 'Delete';
afdh_shortcuts['k'] = 'Keep';
afdh_shortcuts['m'] = 'Merge';
afdh_shortcuts['mv'] = 'Move';
afdh_shortcuts['rd'] = 'Redirect';
afdh_shortcuts['rw'] = 'Rewrite';
afdh_shortcuts['t'] = 'Transwiki';
afdh_shortcuts['wd'] = 'Weak delete';
afdh_shortcuts['sd'] = 'Strong delete';
afdh_shortcuts['sp'] = 'Speedy delete';
afdh_shortcuts['sk'] = 'Strong keep';
afdh_shortcuts['wk'] = 'Weak keep';
afdh_shortcuts['c'] = 'Comment';

afdh_icons = Array();
afdh_icons['d'] = afdh_icons['wd'] = afdh_icons['sd'] = afdh_icons['sp'] = 'Symbol delete vote.svg';
afdh_icons['k'] = afdh_icons['sk'] = afdh_icons['wk'] = 'Symbol keep vote.svg';
afdh_icons['m'] = 'Symbol merge vote.svg';
afdh_icons['c'] = 'Symbol comment vote.svg';

afdh_commscs = Array();
afdh_commscs['pn'] = 'per nom.';

function afd_helper() {
    if (auto_mod())
       return;

    var anchors = new Array();
    {
    var oldanchors = document.getElementById('bodyContent').getElementsByTagName('a');
    for (var i=0; i < oldanchors.length; i++)
        anchors[i] = oldanchors[i];
    }
    var url_re = /\?title=Wikipedia:Articles_for_deletion\/([^&]+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors[i].href.match(url_re))
         || (matches[1].substr(0, 4) == 'Log/'))
            continue;
        var na = document.createElement('a');
        na.href = "javascript:afd_vote('"+escape(anchors[i].href)+"')";
        na.title = "Vote on deletion of "+unescape(matches[1]);
        var inlink = document.createElement('sup');
        inlink.appendChild(document.createTextNode('vote'));
        na.appendChild(inlink);
        anchors[i].parentNode.insertBefore(na, anchors[i].nextSibling);
    }

    if (am_get_title().indexOf(':') == -1)
        am_add_li('tb', 'javascript:afd_nominate()', 'Nominate AFD', '', 'Nominate this article for deletion');
}

function afd_vote(edit_link) {
    var shortcuts_list = '';
    for (var key in afdh_shortcuts)
        shortcuts_list += key + ': ' + afdh_shortcuts[key] + '; ';
    var vote = window.prompt("Enter your vote.   (Shortcuts available are: "+shortcuts_list+")");
    if (!vote) return;
    var icon_link = '';
    if (afdh_useicons && afdh_icons[vote.toLowerCase()])
        icon_link = '[[Image:' + afdh_icons[vote.toLowerCase()] + '|20px]] ';
    if (afdh_shortcuts[vote.toLowerCase()])
        vote = afdh_shortcuts[vote.toLowerCase()];

    shortcuts_list = '';
    for (var key in afdh_commscs)
        shortcuts_list += key + ': ' + afdh_commscs[key] + '; ';
    var comment = window.prompt("Enter your comment.  (Shortcuts available are: "+shortcuts_list+")");
    if (typeof comment != 'string') return;
    if (afdh_commscs[comment.toLowerCase()])
        comment = afdh_commscs[comment.toLowerCase()];

    var summary = vote;
    if (afdh_summaryprompt)
      if (!(summary = window.prompt("Enter the edit summary:", summary)))
         summary = vote;
    var url = edit_link + 
        '&amaddafter='+escape("* '''"+icon_link+vote+"''' "+comment+" "+afdh_signature) +
        '&amsummary='+escape(summary);

    if (window.location.href.indexOf("/Log/") == -1)
      window.location.href = url;
    else
      window.open(url, "afd_helper_vote");
}

function afd_nominate() {
    var title = am_get_title();
    var log_date = window.prompt("This should be the date of the latest AFD log. Change it if necessary.", am_guess_date());
    if (!log_date)
        return;
    var reason = window.prompt("Please justify your AFD nomination of "+title+":");
    if (!reason)
        return;
    window.open(am_make_url(title, '{{'+'subst:afd}}', '', 'nomination for [[WP:AFD|deletion]]'), 'afdhn1');
    window.open(am_make_url('Wikipedia:Articles for deletion/Log/'+log_date, '', '{{'+'subst:afd3|pg='+title+'}}', 'Nominating [['+title+']] for deletion'), 'afdhn3');
    window.location.href = am_make_url('Wikipedia:Articles for deletion/'+title, '', '{{'+'subst:afd2|pg='+title+'|text='+reason+' '+afdh_signature+'}}', 'nominated for deletion');
}

addOnloadHook(afd_helper);

addOnloadHook(function(){ var x; if (x=document.getElementById('wpAnonOnly')) {x.checked=true;} });

//Change my traffic light status page
function edit_status(status)
{
  if (status == 'in')
    statnum = '3';
  else if (status == 'out')
    statnum = '1';
  else statnum = '4'; 
  document.editform.wpTextbox1.value = '<table align=right cellpadding="3" cellspacing="3" style="background-color: lightblue; border: 2px solid black;"><tr><td>[[Image:Traffic lights 4 states ' + statnum + '.png|20px]]</td><td><big>' +"'''I'm " + status + "!'''" + '<br style="clear:both;"> </big><span class="plainlinks">[{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|action=purge}} <small> (Purge Server Cache)</small>]</span></td></tr></table>';
  document.editform.wpSummary.value = status;
}

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

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

function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}


//If you are not editing a page, a tab will appear allowing you to edit the 0th section of a page (the top area usually used as an introduction.

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

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

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

// 

//Hybirdization of ABCD afd closer

function closeafd(bold, notbold){
    var form = document.editform;
    var txt = form.wpTextbox1;
    txt.value = "{{subst:at}} '''" + bold + "'''" + notbold + ". ~~~\n" + txt.value + "\n{{subst:ab}}\n";
    form.wpSummary.value = "close discussion: " + bold + notbold;
    form.wpWatchthis.checked = false;
}

function afdresult(){
    var res = prompt("Result?");
 var day = prompt("On which day was it nominated?");
    if(!res) return;
    var form = document.editform;
    form.wpSummary.value = 'AFD result';
    var txt = form.wpTextbox1;
    txt.value = '{{subst:oldafdfull|date=' + day + ' 06|result=' + res + '|votepage={{subst:PAGENAME}}}} \n' + txt.value;
    txt.focus();
}

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

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

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

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

function inoutaround(msg)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = "{{User:FireFox/Status2|" + msg + "}}";
  f.wpSummary.value = "changing status";
}

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

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

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

function blockuser(msg, other)
{
  var f = document.getElementsByName('wpBlockReason')[0];
  f.value = msg;
  var j = document.getElementsByName('wpBlockOther')[0];
  j.value = other;
}

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

function deleteg(number)
{
  var page = prompt("Which criteria are you deleting under? \n 1: Nonsense \n 2: Test pages \n 3: Vandalism \n 4: Recreation of deleted material \n 7: Author request")
  var f = document.getElementsByName('wpReason')[0];
  f.value = "CSD" + " G" + page + "";
}

function deletea(number)
{
  var page = prompt("Which criteria are you deleting under? \n 1: No context \n 2: Foreign language \n 3: No content, link only, spam \n 6: Attack pages \n 7: Non notable \n 8: Copyvio")
  var f = document.getElementsByName('wpReason')[0];
  f.value = "CSD" + " A" + page + "";
}

function deleter(number)
{
  var page = prompt("Which criteria are you deleting under? \n 1: Redirect to non existant page \n 2: Redirect from main namespace to user namespace \n 3: Typo")
  var f = document.getElementsByName('wpReason')[0];
  f.value = "CSD" + " R" + page + "";
}

function deletei(number)
{
  var page = prompt("Which criteria are you deleting under? \n 1: Redundant \n 2: Corrupt or empty \n 3: Improper license \n 4: No license, no source \n 5: Unused copyrighted images")
  var f = document.getElementsByName('wpReason')[0];
  f.value = "CSD" + " I" + page + "";
}

function deleteo(number)
{
  var page = prompt("What is the page name?")
  var f = document.getElementsByName('wpReason')[0];
  f.value = "[[Wikipedia:Articles for deletion/" + page + "]]";
}

function deletey(number)
{
  var f = document.getElementsByName('wpReason')[0];
  f.value = "uncontested deletion";
}

function testo(number)
{
  var page = prompt("Which AUTOMATICALLY SIGNED message do you want to issue?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:FireFox/" + page + "}}";
  f.wpSummary.value = "Message";
}

function testp(number)
{
  var page = prompt("Which message do you want to issue?")
  var variable= prompt("Is there a variable to go with this template?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "User:FireFox/" + page + "|" + variable + "}}";
  t.value += '\n';
  f.wpSummary.value = "Message";
}

function testq(number)
{
  var page = prompt("Which template(s) do you want to issue?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{" + page + "}}";
  f.wpSummary.value = "{{" + page + "}}";
}

function testq2(number)
{
  var page = prompt("Which template(s) do you want to issue?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + page + "}}";
  f.wpSummary.value = "{{subst:" + page + "}}";
}

function relist(number)
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value += "{{subst:User:FireFox/relist}}";
  f.wpSummary.value = "relist";
}

function list(number)
{
  var page = prompt("Which page are you listing?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
  t.value += "{{" + page + "}}";
  f.wpSummary.value = "+[[" + page + "]]";
}

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

function testr(number)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = "=== User reported ===\n<!-- Please report with the following format (copy and fill in) at the bottom of the list:\n\nIf unregistered IP:\n* {{IPvandal|IP}}  optional brief reason for listing (keep it short) -- ~~~~ \n\nIf registered user:\n* {{vandal|username}} optional brief reason for listing (keep it short) -- ~~~~ \n\nDon't forget to sign with ~~~~ for the timestamp.\n\nPLEASE READ THE PAGE AND WP:VAND BEFORE POSTING A VANDAL HERE; reports that concern content disputes, even heated ones, may be removed without further action.\n\nGenerally, make sure that he or she had vandalised soon after a {{subst:test3}}, {{subst:test4}} or {{subst:bv}} warning. -->\n\n<!--REPORT BELOW HERE! -->";
  f.wpSummary.value = "all blocked, list empty";
}

function tests(number)
{
  var f = document.editform, t = f.wpTextbox1;
  t.value = "=== User reported ===\n<!-- Please report with the following format (copy and fill in) at the bottom of the list:\n\nIf unregistered IP:\n* {{IPvandal|IP}}  optional brief reason for listing (keep it short) -- ~~~~ \n\nIf registered user:\n* {{vandal|username}} optional brief reason for listing (keep it short) -- ~~~~ \n\nDon't forget to sign with ~~~~ for the timestamp.\n\nPLEASE READ THE PAGE AND WP:VAND BEFORE POSTING A VANDAL HERE; reports that concern content disputes, even heated ones, may be removed without further action.\n\nGenerally, make sure that he or she had vandalised soon after a {{subst:test3}}, {{subst:test4}} or {{subst:bv}} warning. -->\n\n<!--REPORT BELOW HERE! -->";
  f.wpSummary.value = "vandal(s) not blocked ( ), list empty";
}

function testt(number)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = "blocked, list not empty";
}

function testu(number)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = "vandal(s) not blocked ( ), list not empty";
}

function support(number)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = "{{subst:User:FireFox/support}} ~~~ support";
}

function oppose(number)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = "{{subst:User:FireFox/oppose}} ~~~ oppose";
}

function neutral(number)
{
  var f = document.editform, t = f.wpTextbox1;
  f.wpSummary.value = "{{subst:User:FireFox/neutral}} ~~~ neutral";
}

// adds various tabs to call the above
function add_tabs()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
 
  // Only add for pages with "Editing User talk:" somewhere in the title
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      addlimenu(tabs, 'talk messages', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/1}} ~~~", "vandalism warning (1)", true, 1)',"test 1");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/2}} ~~~", "vandalism warning (2)", true, 1)',"test 2");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/3}} ~~~", "vandalism warning (3)", true, 1)',"test 3");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/4}} ~~~", "vandalism warning (4)", true, 1)',"test 4");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/bv}} ~~~", "vandalism warning (bv)", true, 1)',"b-vandal");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/b}}", "blocked (vandalism)", true, 1)',"short block");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/i}}", "blocked (vandalism)", true, 1)',"indef block");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/s}}", "blocked (vandalism)", true, 1)',"sock block");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/u}}", "blocked (username)", true, 1)',"username");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/f}}", "blocked (username - non-latin characters)", true, 1)',"non-latin");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/w}}", "welcome", true, 1)',"welcome");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/email}}", "welcome + note", true, 1)',"email");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/Anon}}", "welcome", true, 1)',"anon");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/summary}}", "summary", true, 1)',"summary");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/subst}}", "subst", true, 1)',"subst");
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:User:FireFox/preview}}", "preview", true, 1)',"preview");
    }

  if (document.title.indexOf("Editing User:") != -1)
    {
      addlimenu(tabs, 'userpage tags', 'talkm');
      var talkm = document.getElementById('talkm').getElementsByTagName('ul')[0];
      addlilink(talkm,'javascript:edit_summary_watch("{{subst:ibu}}", "blocked tag", true, 1)',"ibu");
      addlilink(talkm,'javascript:edit_summary_watch("{{WoW}}", "WoW tag", true, 1)',"WoW");
      addlilink(talkm,'javascript:edit_summary_watch("{{WiC}}", "WiC tag", true, 1)',"WiC");
    }

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

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

  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism (section)") == 0)
    {
      addlilink(tabs, 'javascript:testr(1)',"blocked - empty");
    }

  if (document.title.indexOf("Editing Wikipedia:Administrator intervention against vandalism (section)") == 0)
    {
      addlilink(tabs, 'javascript:testt(1)',"blocked - not empty");
    }

  if (document.title.indexOf("Editing Wikipedia:Articles for deletion") == 0)
    {
        addlilink(tabs, 'javascript:relist(1)',"relist");
        addlilink(tabs, 'javascript:closeafd(prompt("Result?"), "")', 'Result');
        addlilink(tabs, 'javascript:closeafd("delete", "")', 'Delete');
    }
        
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/Log") == 0)
    {
      addlilink(tabs, 'javascript:list(1)',"list");
    } 

//  if (document.title.indexOf("Wikipedia:Articles for deletion/Log/") != -1)
//    {
//        addlilink(tabs, 'javascript:hideafd()', 'Hide', 'ca-hide');
//        addlilink(tabs, 'javascript:showafd()', 'Show', 'ca-show');
//   }
 
  if (document.title.indexOf("Editing User:FireFox/Status") == 0)
    {
        addlilink(tabs, 'javascript:inoutaround("in")', "i");
        addlilink(tabs, 'javascript:inoutaround("out")', "o");
        addlilink(tabs, 'javascript:inoutaround("around")', "a");
        addlilink(tabs, 'javascript:inoutaround("busy")', "b");
    }

  if (document.title.indexOf("Block user") == 0)
    {
	addlilink(tabs, 'javascript:blockuser("vandalism", "15 minutes")', "15 minutes");
	addlilink(tabs, 'javascript:blockuser("vandalism", "3 hours")', "3 hours");
	addlilink(tabs, 'javascript:blockuser("vandalism", "24 hours")', "24 hours");
	addlilink(tabs, 'javascript:blockuser("vandalism", "48 hours")', "48 hours");
	addlilink(tabs, 'javascript:blockuser("vandalism", "96 hours")', "96 hours");
	addlilink(tabs, 'javascript:blockuser("vandalism", "indefinite")', "indefinite");
	addlilink(tabs, 'javascript:blockuser("{{username}}", "indefinite")', "username");
	addlilink(tabs, 'javascript:blockuser("contains non-latin characters - {{username}}", "indefinite")', "non-latin");
	addlilink(tabs, 'javascript:blockuser("{{wow}}", "indefinite")', "willy on wheels");
	addlilink(tabs, 'javascript:blockuser("imposter, created solely to impersonate or attack an established user", "indefinite")', "imposter");
	addlilink(tabs, 'javascript:blockuser("please contact an administrator for verification purposes, as described on this page", "indefinite")', "verification");
    }

  if (document.title.indexOf("Unblock user") == 0)
    {
	addlilink(tabs, 'javascript:unblockuser("temporarily removing block (reblock indefinitely)")', "indefinite");
	addlilink(tabs, 'javascript:unblockuser("temporarily removing block (reblock for longer)")', "lengthen");
	addlilink(tabs, 'javascript:unblockuser("temporarily removing block (block conflict)")', "conflict");
	addlilink(tabs, 'javascript:unblockuser("unblock requested (via email)")', "email");
	addlilink(tabs, 'javascript:unblockuser("blocked mistakenly")', "mistake");
	addlilink(tabs, 'javascript:unblockuser("collateral damage")', "collateral");
	addlilink(tabs, 'javascript:unblockuser("remove autoblock")', "autoblock");
    }

  if (document.title.indexOf("Confirm delete") == 0)
    {
      addlilink(tabs, 'javascript:deleteg(1)',"g");
      addlilink(tabs, 'javascript:deletea(1)',"a");
      addlilink(tabs, 'javascript:deleter(1)',"r");
      addlilink(tabs, 'javascript:deletei(1)',"i");
      addlilink(tabs, 'javascript:deletey(1)',"c");
      addlilink(tabs, 'javascript:afddelete()',"!");
    }

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

  if (document.title.indexOf("Editing Wikipedia:Requests for adminship/") == 0)
    {
      addlilink(tabs, 'javascript:edit_summary_watch2("{{subst:User:FireFox/support}}", "support", true, 1)',"support");
    }

}

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

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

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

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

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

  return target;
}

function autoafd()
{
  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 == 'afdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'subst:afd3|pg=' + target + '}}\n';
          document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]';
        }
      else if (action == 'afdsub')
        {
          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 += '{' + '{' + 'subst:afd2|pg=' + target + '|text=' + '}' + '}' +
  '-- ~' + '~' + '~' + '~\n' +
              '\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n*\'\'\' \'\'\'\n';
        }
    }
}

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

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

//From User:Func
if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);

if ( document.createElement && window.addEventListener )
{
 function SoFixItInit() // pre-load, (don't want to slow down loading of article's content, though)
 {

 }

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

 // This is inefficient and not particularly robust.
 // This comes first, I want this link to come up as
 // fast as possible.
 //
 function GetByClass( sElem, sClass )
 { var i, a2 = [], a = document.getElementsByTagName( sElem );
 for ( i = 0; i < a.length; i++ )
 if ( a[ i ].className == sClass )
 a2.push( a[ i ] );
 return a2;
 }
 var a, td = GetByClass( 'td', 'diff-otitle' );
 if ( ( td = td[ 0 ] ) && ( a = td.getElementsByTagName( 'a' )[ 0 ] ) )
 a.href = a.href + '&action=edit'; // need to change text, later

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

 // personal (top-most) menu
 //
 // Celestianpower  Háblame  Prefs  Watchlist  Contribs  Kate  VAN  ESP  Log out  <UTCdate>
 //
 UserMenu.setText( 'pt-mytalk'     , 'Talk'  );
 UserMenu.setText( 'pt-preferences', 'Preferences' );
 UserMenu.setText( 'pt-watchlist'  , 'Watchlist' );
 UserMenu.setText( 'pt-mycontris'  , 'Contributions' );
 UserMenu.setText( 'pt-logout'     , 'Log out'   );
 //
 UserMenu.setHref( 'pt-mycontris',
 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' +
 userName + '&offset=0&limit=50' );
 //
 //
 // it seems there is a stylesheet that makes them lowercase
 //
 // ok, the lowercased menu items are starting to really bug me:
 //
 document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0].style.textTransform = 'none';
 //
 UserMenu.insertBefore( 'pt-esp', 'pt-vandal', 'Status', 'http://en.wikipedia.org/w/index.php?title=User:FireFox/Status&action=edit' );
                if(document.getElementById('ca-edit'))
                       document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';
 // so I always know what time it is in UTC land:
 //
 UserMenu.append( 'pt-utc', UTCTime(), 'javascript:void UserMenu.setText("pt-utc",UTCTime())' );

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

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

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

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

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

 var x = 1;
 NavMenu.append( 'n-' + x++, 'monobook.js', 'http://en.wikipedia.org/w/index.php?title=User:' + userName + '/monobook.js&action=edit' );
 NavMenu.append( 'n-' + x++, 'monobook.css', 'http://en.wikipedia.org/w/index.php?title=User:' + userName + '/monobook.css&action=edit' );
 NavMenu.append( 'n-' + x++, 'AfDs to be closed', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Old' );
 NavMenu.append( 'n-' + x++, 'Todays AfDs', 'http://en.wikipedia.org/wiki/Wikipedia:Articles_for_deletion/Log/Today' );
 NavMenu.append( 'n-' + x++, 'Speedy deletions', 'http://en.wikipedia.org/wiki/CAT:CSD' );
 NavMenu.append( 'n-' + x++, 'RfA and RfB', 'http://en.wikipedia.org/wiki/WP:RFA' );
 NavMenu.append( 'n-' + x++, 'Helpme', 'http://en.wikipedia.org/wiki/Category:Wikipedians looking for help' );
 NavMenu.append( 'n-' + x++, 'Unblock', 'http://en.wikipedia.org/wiki/Category:Requests for unblock' );
 NavMenu.append( 'n-' + x++, 'New users', 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=newusers&user=&page=&limit=20&offset=0' );
 NavMenu.append( 'n- ' + x++, 'Purge', 'http://en.wikipedia.org/w/index.php?title=' + getPname() + '&action=purge' );
 }

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

 // sigh...as far as I can figure, there is empty whitespace being treated
 // as TextNodes....
 //
 var LIs = this.list.getElementsByTagName( 'li' );

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

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

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

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

 return li;
 }

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

 // the ByTagName here is a bit annoying, but in Safari, I was picking
 // up TextNodes by using this[ id ].firstChild.firstChild
 //
 this.getText = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
 this.setText = function( id, txt ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }

 this.getHref = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href       }
 this.setHref = function( id, url ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
 
 // I add em as I need em....
 }

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

 function UTCTime()
 {
 // Get a date stamp for the time in UTC-land.
 //
 // for the future: a format arg
 //
 var s = '',
 d = new Date(),
 a = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' ');
 return d.getUTCDate() + ' ' +
 a[ d.getUTCMonth() ] + ' ' +
 d.getUTCFullYear() + ' ' +
 ( '0' + d.getUTCHours()   ).substr( -2 ) + ':' +
 ( '0' + d.getUTCMinutes() ).substr( -2 ) + ' ' + 'UTC';
 }

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

function NUPatrol()
{
 if ( ( window.location.href.indexOf( 'Special%3ALog&type=newusers' ) == -1 ) &&
 ( window.location.href.indexOf( 'Special:Log/newusers'        ) == -1 )  )
 return; // make more robust???

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

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

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

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

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

 insertLoc = user.nextSibling; // ' newusers '

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

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

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

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

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

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

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

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

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

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

/*

This tool hits the RSS feed for recent changes every 30 seconds or so
and checks for common vandalism. It does not make a separate server request 
for every edit.

Currently, the RSS feed is full of holes and so this may miss many edits.
http://bugzilla.wikimedia.org/show_bug.cgi?id=3942 

*/


// <pre><nowiki>

//DOWNLOADER

recent2={};

recent2.download=function(bundle) {
  // mandatory: bundle.url
  // bundle.onSuccess 
  // bundle.onFailure
  // bundle.otherStuff OK too

  var x = window.XMLHttpRequest ? new XMLHttpRequest()
        : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
        : false;

  if (x) {
    x.onreadystatechange=function() {
      x.readyState==4 && recent2.downloadComplete(x,bundle);
    };
    x.open("GET",bundle.url,true);
    // x.setRequestHeader('Accept','text/*');
    x.send(null); 
  }
}

recent2.downloadComplete=function(x,bundle) {
  x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
  || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText));
}

window.gettingBadWords=false;
window.badWords=null;
recent2.getBadWords=function() {
  window.gettingBadWords=true;
  recent2.download( { url: 'http://en.wikipedia.org/w/index.php?title=User:Lupin/badwords&action=raw&ctype=text/css',
              onSuccess: recent2.processBadWords, onFailure: function () { recent2.runOnce(recent2.getBadWords, 15000); return true;}});
}
recent2.processBadWords=function(d) {
  var data=d.responseText.split('\n');
  var ret=[];
  for (var i=0; i<data.length; ++i) {
    var s=data[i];
    if (s.length==0) continue;
    if (s.charAt(0)=='<') continue;
    ret.push(s.replace(RegExp('([-|.()\\+:!,?*^${}\\[\\]])', 'g'), '\\$1'));
  }
  //                                             ((    repeatedchar      )       |   ( ...  | ... | ...    ))( bdy   )
  window.badWords=RegExp("<td>[+]</td><td .*?>.*?(([^-{}.\\s'=wI:*#0-9A-F])\\2{2,}|\\b(" + ret.join('|') + "))(\\b|[|]).*</td>", 'im');
}

window.gettingWatchlist=false;
window.watchlist=null;
window.getWatchlist=function() {
  window.gettingWatchlist=true;
  recent2.download({url: 'http://en.wikipedia.org/wiki/Special:Watchlist/edit', 
              onSuccess: processWatchlist, onFailure: function () { recent2.runOnce(getWatchlist, 15000); return true; }});
}
window.processWatchlist=function(req, bundle) {
  var watchlist={};
  var lines=req.responseText.split('\n');
  for (var i=0; i<lines.length; ++i) {
    if (lines[i].indexOf('<li><input type="checkbox" name="id[]" value=') > -1) {
      var article=lines[i].replace(/.*title="(.*?)">.*/, '$1');
      watchlist[article]=true;
    }
  }
  window.watchlist=watchlist; 
}


recent2.runOnce=function(f, time) {
  var i=recent2.runOnce.timers.length;
  var ff = function () { clearInterval(recent2.runOnce.timers[i]); f() };
  var timer=setInterval(ff, time);
  recent2.runOnce.timers.push(timer);
}
recent2.runOnce.timers=[];

var feed='http://en.wikipedia.org/w/index.php?title=Special:Recentchanges&feed=rss';

window.newOutputDiv=function(klass, position, immortal) {
  var h1=document.getElementsByTagName('h1')[0];
  var ret=document.createElement('div'); 
  if (klass) ret.className=klass;
  if (!position) position='bottom';
  switch(position) {
  case 'top': 
    h1.parentNode.insertBefore(ret, h1.nextSibling);
    break;
  case 'bottom':
    h1.parentNode.appendChild(ret);
    break;
  default:
    if (!newOutputDiv.alerted) {
      alert('Unknown position '+position+' in recent2.js, newOutputDiv');
      window.newOutputDiv.alerted=true;
    }
    return newOutputDiv(klass, 'bottom');
  }
  if (!immortal) { ret.id=newOutputDiv.uid++; }
  window.outputDivs.push(ret);
  return ret;
}
window.newOutputDiv.alerted=false;
window.newOutputDiv.uid=0;
window.outputDivs=[];

window.grabRecentChanges=function(feed) {
  if (! window.badWords && recent2.filter_badwords ) {
    if ( ! window.gettingBadWords ) recent2.getBadWords();
    return recent2.runOnce(function(){grabRecentChanges(feed);}, 500);
  }
  if (! window.watchlist && recent2.filter_watchlist) { 
    if (! window.gettingWatchlist ) getWatchlist();
    return recent2.runOnce(function(){grabRecentChanges(feed);}, 500);
  }
  var pos=recent2.outputPosition;
  if (recent2.outputPosition=='top') {
    var output=newOutputDiv('recent2.lines', pos);
    var status=newOutputDiv('recent2.status', pos);
  } else {
    var status=newOutputDiv('recent2.status', pos);
    var output=newOutputDiv('recent2.lines', pos);
  }
  status.style.borderStyle='solid';
  status.style.borderColor='orange';
  status.innerHTML=greyFont+'(' + count + ') updating...</font>';

  recent2.download({url: feed, onSuccess: processRecentChanges, output: output, status: status, onFailure: feedFailed});
}

var greyFont='<font color="#777">';

window.feedFailed=function(x,bundle) {
  try { bundle.status.innerHTML+=greyFont+'failed: '+x.statusText + '</font>'; } 
  catch (err) { bundle.status.innerHTML+=greyFont+'failed badly: '+err+'</font>'; }
  return true;
}

recent2.newWindows=true;

window.linkmaker=function(url, text) {
  var s='<a href="' + url + '"';
  recent2.newWindows && (s += ' target="_blank"');
  s += '>' + text + '</a>';
  return s;
}


recent2.ipUserRegex=RegExp('(User:)?((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])');

window.processRecentChanges=function(req, bundle){  
  var initialId=processRecentChanges.id;
  var doc=req.responseXML.documentElement;
  var items=doc.getElementsByTagName('item');
  var latest=processRecentChanges.lastDate;
  var output=[]; // <ul class="special">';
  for (var i=0; i< items.length; ++i) {
    var timestamp = Date.parse(getFirstTagContent(items[i],'pubDate'));
    if (timestamp <= processRecentChanges.lastDate) continue;
    latest = (timestamp > latest) ? timestamp : latest;
    var diffText=getFirstTagContent(items[i],'description').split('</tr>').join('</tr>\n');
    var editSummary=diffText.replace(RegExp('^<p>(.*?)</p>[\\s\\S]*'), '$1');
    var editor=getFirstTagContent(items[i], 'creator') || getFirstTagContent(items[i], 'dc:creator');
    
    if (recent2.filter_anonsOnly && !recent2.ipUserRegex.test(editor)) continue;

    var articleTitle=getFirstTagContent(items[i], 'title');
    if (! recent2.show_talkpages && articleTitle && /^Talk:|^[^:]*?[_ ]talk:/.test(articleTitle)) continue;
    if (recent2.filter_watchlist && articleTitle && 
        ! window.watchlist[articleTitle.replace(/^Talk:/, '').replace(/[ _]talk:/, ':')]) continue;
    
    if (recent2.filter_badwords) {
      var badMatch=null;
      if (window.vandals[editor] > 0) badMatch=['', '[previously rolled back this editor]'];
      else badMatch=badWords.test(diffText); // .test() is meant to be faster than a full match
      if (badMatch) {
        badMatch=diffText.match(badWords);
        var article=getFirstTagContent(items[i], 'link');
        articleTitle=getFirstTagContent(items[i], 'title');
        var id=processRecentChanges.id;
        // highlighting
        badMatch[0]=badMatch[0].split(badMatch[1]).join('<span style="background-color: #FF6">'+badMatch[1]+'</span>');
        output.push(recent2.doLine({timestamp: timestamp, article:article, articleTitle:articleTitle, 
                                                 editor:editor, id:id, badWord:badMatch[1], badDiffFragment:badMatch[0], diff:diffText,
                                                 summary:editSummary}));
        processRecentChanges.id++;
      }
    }
    else {
      var article=getFirstTagContent(items[i], 'link');
      var articleTitle=getFirstTagContent(items[i], 'title');
      if (recent2.CustomFilter && 
          ! recent2.CustomFilter({timestamp:timestamp, article:article, articleTitle:articleTitle, 
                                         editor:editor, diff:diffText, summary:editSummary})) continue;
      var id=processRecentChanges.id;
      output.push(recent2.doLine({timestamp: timestamp, article:article, articleTitle:articleTitle,
                                               editor:editor, id:id, diff:diffText, summary:editSummary}));
      processRecentChanges.id++;
    }

  } /* end for loop */
  //output+='</ul>';
  var outputString='';
  if (recent2.outputPosition=='top') {
    outputString=output.join('');
  }
  else {
    for (var i=output.length-1; i>=0; --i) {
      outputString+=output[i];
    }
  }
  bundle.output.innerHTML+=outputString;
  recent2.runOnce(function() {recent2.doPopups(bundle.output)}, 300);
  processRecentChanges.lastDate=latest; // - 1; // overlap better than missing some out, i think; FIXME do this properly
  var statusTail=greyFont+'done up to ' + formatTime(latest) + '</font>';
  if (processRecentChanges.id > initialId) {
    statusTail+=' <a href="javascript:showHideDetailRange(' + initialId + ',' + processRecentChanges.id  + ')">toggle these details</a> |';
  }
  statusTail += ' <a href="javascript:deleteEarlierOutputDivs(' + bundle.status.id + ')">remove earlier output</a>';
  statusTail+='<br>';
  bundle.status.innerHTML+=statusTail;
}
processRecentChanges.lastDate=0;
processRecentChanges.id=0;

window.deleteEarlierOutputDivs=function(cur) {
  for(var i=0; i<outputDivs.length; ++i) {
    if (!outputDivs[i] || !outputDivs[i].id) continue;
    if (outputDivs[i].id >= 0 && outputDivs[i].id < cur) {
      // FIXME BUG: if we go from the bottom up, then we'll delete one too many or too few, or something :-)
      outputDivs[i].parentNode.removeChild(outputDivs[i]);
      outputDivs[i]=null;
    }
  }
  // scroll to the top if we're appending output to the bottom, to keep the div we've clicked visible after the deletions
  if (recent2.outputPosition!='top') document.location='#';
}

window.showHideDetailRange=function(start,end) {
  // use the first div to see if we should show or hide
  var div=document.getElementById('diff_div_' + start);
  if (!div) return;
  var state=false; // hide
  if (div.style.display=='none') state=true; // show
  for (var i=start; i<end; ++i) {
    showHideDetail(i, true, state);
  }
}

window.toggleSysopEdits=function() {
  var divs=document.getElementsByTagName('div');
  for (var i=0; i<divs.length; ++i) {
    if (divs[i].className=='sysop_edit_line') divs[i].style.display= ( toggleSysopEdits.hidden ? 'none' : 'inline' );
  }
  toggleSysopEdits.hidden = ! toggleSysopEdits.hidden;
}

window.bundles={};

window.vandalColour = function(vandal) {
  var num=window.vandals[vandal];
  if (!num) return '';
  switch (num) {
  case 1: return '#DDFFDD';
  case 2: return '#BBFFBB';
  }
  var i= 9-(num - 3) *2;
  if (i < 0) i=0;
  return '#' + i + i + 'FF' + i + i;
}

window.clickDetails=function(action, max) {
  if(!action) action='show';
  if (!max) max = document.links.length;
  var count=0;
  for (var i=0; i<document.links.length && count < max; ++i) {
    if(document.links[i].innerHTML==action + ' details' && document.links[i].href.indexOf('javascript:') == 0) {
      ++count; 
      eval(document.links[i].href.replace('javascript:', ''));
    }
  }
}


recent2.pendingLines=[];

recent2.togglePausedOutput=function() {
  if (!recent2.pausedOutput) { recent2.pausedOutput = true; return true; }
  else recent2.pausedOutput=false; 
  var outputBuffer='';
  while (recent2.pendingLines.length) {
    outputBuffer+=recent2.doLine(recent2.pendingLines.pop());
  }
  var pos=recent2.outputPosition;
  var output=newOutputDiv('recent2.lines', pos);
  output.innerHTML=outputBuffer;
  return false;
}

recent2.togglePaused=function() {
  if(!recent2.paused) { recent2.paused=true; return true; }
  recent2.paused=false;
  loopRecentChanges(loopRecentChanges.url, loopRecentChanges.iterations);
  return false;
}

recent2.doLine=function(bundle) {
  if (recent2.pausedOutput) {
    recent2.pendingLines.push(bundle);
    return '';
  }
  var wikiBase='http://en.wikipedia.org/wiki/';
  var sysop = null;
  if (typeof sysops != 'undefined') sysop=sysops.test(bundle.editor);
  var lastDiffPage=bundle.article + '?diff=cur&oldid=prev';
  bundle.url=lastDiffPage;
  saveBundle(bundle);
  var div='';
  if (window.vandals[bundle.editor] > 0) { div='<div style="background-color:' + vandalColour(bundle.editor) + '">'}
  else if (sysop) {div='<div class="sysop_edit_line">'};
  return div +
  '<li>' +
  formatTime(bundle.timestamp) + ' ' +
  //latest + ' ' + processRecentChanges.lastDate + ' ' +
  linkmaker(lastDiffPage, bundle.articleTitle) +
  ( bundle.badWord ? ' matched <b>' + bundle.badWord + '</b> . . ' : ' . . ') +
  linkmaker(wikiBase + 'User:' + bundle.editor,           bundle.editor)     + ' ('  +
  linkmaker(wikiBase + 'User_talk:' + bundle.editor,             'talk')     + ' | ' +
  linkmaker(wikiBase + 'User_talk:' + bundle.editor + '?action=edit' +
            '&autoedit=s#$#\\n{{subst:bv-n|' + bundle.articleTitle + '}}%20~~~~#&autosummary=Your%20recent%20edits',
            'warn')     + ' | ' +
  linkmaker(wikiBase + 'Special:Contributions/' + bundle.editor, 'contribs') + ' | ' +
  linkmaker(wikiBase + 'Special:Blockip/' + bundle.editor,       'block')    +  ') . . ' +
  ( bundle.summary ? '<i>('+bundle.summary+')</i> . . ' : '') +
    '<a href="javascript:showHideDetail(' + bundle.id + ')" id="showdiff_link_' + bundle.id + '">show details</a>' +
    ' [<a href="javascript:tryRollback(' + bundle.id + ')">rollback</a>]' +
  '<p><div id="diff_div_' + bundle.id + '" style="display: none">' +
  '</div></li>' +
  ( div ? '</div>' : '') ;
}

window.saveBundle= function(bundle) {
  var z={};
  for (var prop in bundle) { z[prop]=bundle[prop]; }
  window.bundles[bundle.id]=z;
}

window.vandals={}

window.tryRollback=function(id) {
  var b=window.bundles[id];
  var vandal=b.editor;
  if (window.vandals[vandal]==null) window.vandals[vandal]=1;
  else window.vandals[vandal]++;
  if (!b) { alert('No bundle! Please tell Lupin how to reproduce this error - it should not really happen.'); return; }
  var onSuccess=function (x, bundle) {
    var rollRe=RegExp('<a href="(/w/index.php[^"]*?action=rollback[^"]*?from=([^&]*)[^"]*?)".*?<br />(<span[^>]*>)?(.*?)(</span>)?<br /></td>');
    // match[0]: useless
    // match[1]: url (escaped)
    // match[2]: last editor (escaped)
    // match[4]: last edit summary (wikiText - FIXME strip this to plain text)
    var match=rollRe.exec(x.responseText);
    if (!match) {
      alert('No rollback link found.\nSadly rollback is only available to admins. Alternatively, this may be a bug.');
      return;
    }
    var lastEditor=match[2].split('+').join(' ');
    var lastSummary=match[4];
    // var vandal=b.editor; // from the closure
    if (lastEditor != vandal) {
      var summary=lastSummary.replace(RegExp('<[^>]*?>','g'),'');
      if (!summary) summary=lastSummary;
      alert( 'Could not rollback - someone else has edited since the vandal.\n\nPage: '+ b.articleTitle +
             '\nVandal: '+vandal+'\nLast editor: '+lastEditor+'\nEdit summary: '+summary);
      return;
    }
    var rollbackUrl=match[1].split('&amp;').join('&');
    // confirm('Rollback edits by '+vandal + ' to '+b.articleTitle+'?') && 
    window.open(rollbackUrl, '_blank');
  }
  var onFailure = function(x,bundle) {
    alert('HTTP failed when trying to get rollback link in url\n' + bundle.url +
          '\n\nHTTP status text: ' + x.statusText);
    return true;
  }
  recent2.download({ url:b.url, onSuccess: onSuccess, id: b.id, onFailure:onFailure});
}

recent2.doPopups=function(div) {
  if (typeof(mouseOverWikiLink)!='undefined' && 
      typeof(mouseOutWikiLink) !='undefined' && 
      typeof(killPopup)        !='undefined') {
    var anchors=div.getElementsByTagName('A');
    for (var i=0; i<anchors.length; ++i) {
      var a=anchors[i];
      if (a.href.indexOf('javascript')==0) continue;
      a.onmouseover=mouseOverWikiLink;
      a.onmouseout= mouseOutWikiLink;
      a.onclick= killPopup;
    }
  }
}

window.formatTime=function(timestamp) {
  var date=new Date(timestamp);
  nums=[date.getHours(), date.getMinutes(), date.getSeconds()];
  for (var i=0; i<nums.length; ++i) if (nums[i]<10) nums[i]='0'+nums[i];
  return nums.join(':');
}

window.showHideDetail = function(id, force, state) {
  var div=document.getElementById('diff_div_' + id);
  var lk=document.getElementById('showdiff_link_' + id);
  if (!div) return;
  var bundle=window.bundles[id];
  if (!div.innerHTML) div.innerHTML= ( bundle.badDiffFragment ? bundle.badDiffFragment:'') + bundle.diff;
  if ((force && state==true) || (!force && div.style.display=='none')) { div.style.display='inline'; lk.innerHTML='hide details'; }
  else { div.style.display='none';   lk.innerHTML='show details'; }
    
}


window.getFirstTagContent=function(parent, tag) {
  var e=parent.getElementsByTagName(tag);
  if (e && (e=e[0]) ) {
    var ret = e.firstChild.nodeValue || e.nodeValue; 
    if (typeof ret != typeof '') return '';
    return ret; 
  }
}

recent2.controlUI=function() {
  recent2.controls=newOutputDiv('recent2.controls', 'top', true);
  var talk=document.createElement('input');
  talk.type='checkbox';
  talk.checked=!recent2.show_talkpages;
  talk.onclick=function(){ recent2.show_talkpages=!this.checked; }
  recent2.controls.appendChild(talk);
  recent2.controls.talk=talk;
  var label=document.createElement('label');
  label.innerHTML='Hide talk pages';
  recent2.controls.appendChild(label);
}

var count=0;
window.loopRecentChanges=function(url, iterations) {
  if (!iterations) iterations=20;
  loopRecentChanges.iterations=iterations;
  loopRecentChanges.url=url;
  grabRecentChanges(url);
  recent2.runOnce(function () { 
    if (recent2.paused) {++count; return; }
    if (++count >= iterations && ! confirm('Continue monitoring recent changes?') ) return; 
    count %= iterations; loopRecentChanges(url, iterations);
  }, 30000);
}
window.marvin=function() { 
  window.sysops=RegExp("^(\\-\\- April|23skidoo|A Man In Black|ABCD|ALoan|Academic Challenger|Acetic Acid|Adam Bishop|Ahoerstemeier|Alabamaboy|Alai|AlainV|Alex S|Alex756|AlistairMcMillan|Alkivar|Allen3|AllyUnion|Alteripse|Ambi|Ams80|Andres|Andrevan|Andrew Yong|Andrewa|Andris|Android79|Angela|Angr|Antandrus|Anthere|AntonioMartin|Aranel|Arcadian|Aris Katsaris|Arminius|Arvindn|Arwel Parry|Asbestos|AstroNomer|Ausir|AxelBoldt|BanyanTree|BaronLarf|Bcorr|Bdesham|Bearcat|Beland|Benc|Bhadani|Biekko|BillyH|Bishonen|Bkonrad|Blankfaze|Bluemoose|Bmicomp|Bovlb|Bratsche|Brian Kendig|Brian0918|BrianSmithson|Briangotts|Brighterorange|Brion VIBBER|Brockert|BrokenSegue|Brookie|Bryan Derksen|Bumm13|Burgundavia|CJCurrie|COGDEN|CSTAR|CYD|Cacycle|Caltrop|CambridgeBayWeather|Camembert|Canderson7|Capitalistroadster|Carbonite|Carnildo|Catbar|CatherineMunro|Cburnett|Cdc|Cecropia|Cedar\\-Guardian|Celestianpower|CesarB|Cgs|Chadloder|Chancemill|Changlc|Charles Matthews|Chmod007|Chris 73|Chris Roy|ChrisO|Christopher Mahan|Chuck SMITH|Chuq|Cimon avaro|Clarkk|Clifford Adams|ClockworkSoul|Commander Keane|ContiE|Cool Hand Luke|Cprompt|Craigy144|Cryptic|CryptoDerk|Curps|Cutler|Cyan|Cyberjunkie|CyborgTosser|Cyp|Cyrius|DESiegel|DF08|DJ Clayworth|Dale Arnett|Dan100|DanKeshet|Daniel Quinlan|DanielCD|Danny|Dante Alighieri|Darwinek|Dave souza|David Gerard|David Newton|David\\.Monniaux|DavidLevinson|DavidWBrooks|Davidcannon|Davodd|Dbachmann|Dbenbenn|Dbiv|Dcoetzee|Deb|Decumanus|Delirium|Denelson83|Denni|Derek Ross|Dgrant|Diberri|Dieter Simon|Dino|Dmcdevit|Dmn|Doc glasgow|Docu|Dori|Dpbsmith|DrBob|DragonflySixtyseven|Dragons flight|Drini|DropDeadGorgias|Duk|Duncharris|Durin|Dvyost|Dwheeler|Dysprosia|Earl Andrew|Ed Poor|Ed g2s|Edcolins|Edward|Efghij|Egil|El C|Elf|Ellsworth|Eloquence|Enchanter|Essjay|Eugene van der Pijll|Evercat|Everyking|Evil Monkey|Evil saltine|Evilphoenix|Exploding Boy|Ezhiki|FCYTravis|Fabiform|Fantasy|Fastfission|Fawcett5|Feco|FeloniousMonk|Fennec|Ferkelparade|Fernando Rizo|Ffirehorse|Filiocht|Finlay McWalter|Fire Star|FireFox|Flcelloguy|Flockmeal|Francs2000|Frazzydee|Fred Bauder|Fredrik|Freestylefrappe|FreplySpang|Friday|Func|Furrykef|Fuzheado|Fvw|G\\-Man|Gabbe|Gadfium|Gamaliel|Garzo|Gaz|Gdr|GeneralPatton|Geni|Gentgeen|Geogre|Gerald Farinas|Goatasaur|Golbez|Graft|GregAsche|GregRobson|Grenavitar|Grm wnr|Ground Zero|Grue|Grunt|Grutness|Gtrmp|Guettarda|Gwalla|Gyrofrog|Hadal|Hajor|Hall Monitor|HappyCamper|Hashar|Hawstom|Hcheney|Hedley|Hemanshu|Henrygb|Hephaestos|Hermione1980|Heron|Homeontherange|Humblefool|Hyacinth|Icairns|IceKarma|Ihcoyc|Ike9898|Ilyanep|Improv|Imran|Infrogmation|Ingoolemo|Inter|Isomorphic|Ixfd64|J\\.J\\.|JCarriker|JHK|JIP|JRM|JYolkowski|Jake Nelson|Jallan|JamesTeterenko|Jamesday|Jasonr|Jaxl|Jay|Jayjg|Jcw69|Jdavidb|Jdforrester|JeLuF|Jeffrey O\\. Gustafson|Jengod|JeremyA|Jeronimo|Jerzy|JesseW|Jfdwolff|Jiang|Jimbo Wales|Jimfbleak|Jimregan|Jinian|Jitse Niesen|Jmabel|Jnc|Jni|JoJan|John Kenney|JohnOwens|Johnleemk|Johntex|JonMoore|Jondel|Joolz|Josh Grosse|Jossifresco|Journalist|Joy|Joy Stovall|Jpgordon|Jrdioko|Jredmond|Jtdirl|Jtkiefer|Justinc|Jwrosenzweig|K1Bond007|KF|Kaihsu|Kaldari|Karada|Karen Johnson|Karmafist|Katefan0|Kbdank71|Kelly Martin|Khaosworks|Khendon|Khym Chanur|Kingturtle|Kirill Lokshin|Kmccoy|Knowledge Seeker|Kosebamse|Ktsquare|Kwamikagami|Kzollman|LC|Lachatdelarue|Lacrimosus|Lectonar|Lee Daniel Crocker|Lexor|Linuxbeak|LittleDan|Llywrch|Lommer|Longhair|Lord Emsworth|LordAmeth|LouI|Lowellian|Lucky 6\\.9|Ludraman|Lupin|Lupo|MC MasterChef|MacGyverMagic|Mackensen|Mackeriv|Madchester|Magnus Manske|Mailer diablo|Mairi|Malcolm Farmer|Manning Bartlett|Marianocecowski|Marine 69\\-71|Mark|Mark Christensen|Mark Dingemanse|Mark Richards|MarkSweep|Markalexander100|Marshman|Marudubshinki|Marumari|Master Thief Garrett|Matt Crypto|Maury Markowitz|Maveric149|Maximus Rex|Mbecker|Meelar|Mel Etitis|Menchi|Merovingian|Merphant|Mic|Michael Hardy|Michael Snow|Mike Halterman|Mikkalai|Mindspillage|Minesweeper|Mintguy|Mirv|Mirwin|Mkmcconn|Mkweise|Modemac|Moink|Moncrief|Montrealais|Moriori|Morven|Morwen|Mulad|Mustafaa|MyRedDice|MykReeve|Mysekurity|Mzajac|Nabla|Nandesuka|Nanobug|Necrothesp|Neutrality|Ngb|Nichalp|NicholasTurnbull|Nickptar|Nickshanks|Niteowlneils|Nohat|Noldoaran|Notheruser|Nufy8|Nunh\\-huh|Nv8200p|Oberiko|OldakQuill|Oleg Alexandrov|Oliver Pereira|Olivier|Omegatron|Optim|Ortolan88|Oven Fresh|OwenX|PFHLai|PMA|PRueda29|PZFUN|Pakaran|Pamri|Patrick|Paul A|Paul August|Pcb21|PedanticallySpeaking|Petaholmes|Peter Winnberg|Pfortuny|Pharos|Phil Bordelon|Phil Boswell|Phils|Philwelch|Phroziac|Physchim62|PierreAbbat|Piotrus|Pjacobi|Pollinator|Poor Yorick|Postdlf|Pratyeka|Premeditated Chaos|Proteus|Psy guy|Qaz|Quadell|Quercusrobur|R\\. fiend|R3m0t|RHaworth|RJFJR|RN|Radiant\\!|RadicalBender|Ragib|Ral315|Ram\\-Man|Rama|Ramallite|Ran|Raul654|Rbrwr|Rd232|Rdsmith4|RedWolf|RedWordSmith|Redux|Redwolf24|Refdoc|Reflex Reaction|Rfl|Rhobite|Rholton|Rhymeless|Rich Farmbrough|Rick Block|RickK|Rje|Rlandmann|Rlquall|Rmhermen|Roadrunner|RobLa|Robchurch|Robert Merkel|RobertG|Robin Patterson|RobyWayne|Roozbeh|RoseParks|Rossami|RoyBoy|RoySmith|Rx StrangeLove|Ryan Delaney|SD6\\-Agent|SWAdair|Salsa Shark|Sam Hocevar|Sam Korn|Sango123|Sannse|Sarge Baldy|Sasquatch|Schissel|Schneelocke|Scimitar|Scipius|Scott Burley|ScottDavis|Seabhcan|Sebastiankessel|Secretlondon|Seglea|Sesel|Seth Ilys|Sfoskett|Shanes|Shauri|Sheldon Rampton|Shimgray|SimonP|Siroxo|Sj|Sjakkalle|Sjc|Slambo|SlimVirgin|Slowking Man|Slrubenstein|Smith03|Sn0wflake|Snowspinner|Snoyes|Solipsist|Someone else|Sortior|Spangineer|Spencer195|Splash|Ssd|Stan Shebs|Starblind|Stevenj|Stevertigo|Stewartadcock|Stormie|Sugarfish|Sundar|Sverdrup|TPK|TUF\\-KAT|Ta bu shi da yu|Talrias|Tannin|Tarquin|Taw|Taxman|TenOfAllTrades|Texture|Thames|The Anome|The Cunctator|The Epopt|The Singing Badger|The wub|TheCoffee|TheoClarke|Theresa knott|Thryduulf|Thue|Thunderbrand|Tillwe|Tim Ivorson|Tim Starling|Timc|Timrollpickering|Timshell|Timwi|Titoxd|Tkinias|Toby Bartels|Tom\\-|Tomf688|Tompagenet|Tony Sidaway|Topbanana|Tregoweth|Trevor macinnis|Triddle|Trilobite|Tristanb|Ugen64|Ulayiti|Uncle G|UninvitedCompany|Urhixidur|Utcursch|UtherSRG|Vague Rant|VampWillow|Vancouverguy|Vaoverland|Viajero|Vicki Rosenzweig|Violetriga|Visorstuff|Voice of All\\(MTG\\)|Vsmith|Waltpohl|Wapcaplet|Warofdreams|Wayward|Wernher|Wesley|WhisperToMe|Who|Wiglaf|Wikiacc|Wikibofh|Wile E\\. Heresiarch|Wilfried Derksen|Willmcw|Woggly|WojPob|Woohookitty|Worldtraveller|Ww|Wwoods|XJamRastafire|Xezbeth|Y0u|Yacht|Zanimum|Zero0000|Zippy|Zocky|Zoe|Zoicon5|Zoney|Zscout370|Zzyzx11)$");
  recent2.show_talkpages=true;
  recent2.controlUI();
  loopRecentChanges(feed, 200); 
}

// **************************************************
// Installation
// **************************************************

recent2.addlilink=function(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;
}

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

window.addMarvin=function() {
  recent2.addToolboxLink('http://en.wikipedia.org/wiki/User:Lupin/Filter_recent_changes', 'Filter recent changes', 'toolbox_filter_changes');
  recent2.addToolboxLink('http://en.wikipedia.org/wiki/User:Lupin/All_recent_changes', 'All recent changes', 'toolbox_all_changes');
  recent2.addToolboxLink('http://en.wikipedia.org/wiki/User:Lupin/Recent_IP_edits', 'Recent IP edits', 'toolbox_IP_edits');
  recent2.addToolboxLink('http://en.wikipedia.org/wiki/User:Lupin/Monitor_my_watchlist', 'Monitor my watchlist', 'toolbox_watchlist_edits');
  //document.getElementById('toolbox_filter_changes').onclick=marvin;
}

window.maybeStart=function() {
  var loc=document.location.href;
  if (RegExp('User:Lupin/Filter[_ ]recent[_ ]changes','i').test(loc)) {
    recent2.filter_badwords=true;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/All[_ ]recent[_ ]changes','i').test(loc)) {
    recent2.filter_badwords=false;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/Recent[_ ]IP[_ ]edits','i').test(loc)) {
    recent2.filter_anonsOnly=true;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/Monitor[_ ]my[_ ]watchlist', 'i').test(loc)) {
    recent2.filter_watchlist=true;
    recent2.runOnce(marvin, 1000);
  }
}

// adds a 'logs for this page' link to the navigation bar
// if the page is a user's page, talk page or subpage, the link will go to logs for the user instead
// if the page is a special page, then no link is displayed

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");

});

// 

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

// 

// onload 
addOnloadHook(maybeStart);
addOnloadHook(addMarvin);

/// Local Variables: ///
/// mode:c ///
/// fill-prefix:"// " ///
/// End: ///

addOnloadHook(function () {
    var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]=";
    //var query_prefix = "action=unwatch&title=";

    if (window.location.href.indexOf("Special:Watchlist") == -1) return;
    var links = document.getElementById('content').getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
        if (links[i].href.substring(links[i].href.length-15) != '&action=history')
            continue;
        var unwatch = document.createElement('a');
        unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title);
        unwatch.title = "Unwatch "+links[i].title;
        unwatch.appendChild(document.createTextNode("unwatch"));
        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
        // kluge to handle case where "diff" is unlinked:
        var delim = links[i].previousSibling;
        delim = (delim.nodeType == 3 ? delim.nodeValue : "");
        links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch);
    }
});

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

//[[Category:VoA scripted admins|{{PAGENAME}}]]<pre><nowiki>
//NOTE: for security override HTTP request info for commons image duplicates script:
//For FF/NS, go enable, see "http://esw.w3.org/topic/SparqlCalendarDemoUsage#FAQ"
//Basically, enable "signed.applets.codebase_principal_support" in about:config 
//Reduce IE security settings for future versions (this does not support IE yet)

//Helper tools

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

function checkall()
{
  form = document.getElementById('bodyContent');
  l = form.getElementsByTagName('input');
  for (i = 0 ; i < l.length; i++)
    {
    if (l[i].type == 'checkbox')
      {l[i].value = '1'; l[i].checked=true;}
    }
}
//END

//
Mvaluejsadmin = 'move';
Rvaluejsadmin = 'revert';
Uvaluejsadmin = 'upload';
//

//MASTER rollback
addOnloadHook(addmasterroll)
function addmasterroll()
{
  var undefined;
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  if (location.href.indexOf(':Contributions') != -1 || location.href.indexOf('&title=Special%3AContribution') != -1 && location.href.search(/\d{1,3}(@|%40)\d{1,2}/) == -1) 
      { 
    addTab("javascript:masterlogview(100,'move')", "moves", "ca-viewpm", "Views user's page moves", "");
    addTab("javascript:masterlogview(50,'upload')", "uploads", "ca-viewpm", "Views user's page moves", "");
    addTab("javascript:masterroll()", "{{Revert all edits}}", "ca-massroll", "Rollback user's top edits", "");
    addTab("javascript:number_count()", "#", "ca-numb", "Number edits", "");
      }
  else if (location.href.indexOf(':Contributions') != -1 || location.href.indexOf('&title=Special%3AContribution') != -1 && location.href.search(/\d{1,3}(@|%40)\d{1,2}/) != -1) 
      { 
    addTab("javascript:masterroll()", "{{Revert all edits}}", "ca-massroll", "Rollback users' top edits", "");
      }
  else if (document.title.indexOf('Move log') != -1 && location.href.search('&user=[^&]') !=-1) 
      { 
    addTab("javascript:movemasterroll()", "{{{Revert all Moves}}}", "ca-rvmoves", "Reverts user's page moves", "");
      }
  else if (document.title.indexOf('Upload log') != -1 && location.href.search('&user=[^&]') !=-1) 
      { 
    addTab("javascript:masterdelete()", "{{Revert all uploads}}", "ca-rvmoves", "Reverts uploads", "");
      }
  else if (document.title.indexOf('View and restore deleted pages') != -1)
      {
    addTab("javascript:checkall()", "{{Check all revisions}}", "ca-checkall", "Check all deleted revisions", "");
      }
  else if (location.href.search(/&action=history|Special:Log|title=Special%3ALog/) != -1)
    {addTab("javascript:number_count()", "#", "ca-numb", "Number edits", "");}
}
//END

function number_count()
{
var l = document.getElementsByTagName('ul')[0].getElementsByTagName('li');
if (l[0].innerHTML.indexOf('<strong>#1</strong> ') != -1)
{return;}
for (var i=0; i < l.length; i++)
   {
   var c = i+1;
   l[i].innerHTML = '<strong>#' + c + '</strong> ' + l[i].innerHTML;
   }
}

function masterlogview(number,type)
{
    var c = document.getElementById('contentSub');
    var a = c.getElementsByTagName('a');
    vandal = a[0].href;
    if (vandal.split("User:")[1] != undefined)
         {
      vandalb = vandal.split("User:")[1];
           if (vandalb.split("&action=edi")[1] != undefined)
             {
          vandalc = vandalb.split("&action=edit")[0];
          location.href = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=' + type + '&user=' + vandalc + '&page=&limit=' + number;
             }
          else
             {
          location.href = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=' + type + '&user=' + vandalb + '&page=&limit=' + number;
             }
       }
   else if (vandal.split("User_talk:")[1] != undefined)
         {
      vandalb = vandal.split("User_talk:")[1];
           if (vandalb.split("&action=edi")[0] != undefined)
             {
          vandalc = vandalb.split("&action=edit")[0];
          location.href = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=' + type + '&user=' + vandalc + '&page=&limit=' + number;
             }
          else
             {
          location.href = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=' + type + '&user=' + vandalb + '&page=&limit=' + number;
             }
       }
}
//END

//////////////Auto-actions//////////////
function winclosed()
{
 if (location.href.indexOf('&fakaction=masterfill') != -1 && document.title.indexOf('Move page') != -1)
    {
    document.getElementById('wpReason').value = 'Automated revert of mass page moving.';
    document.getElementById('movepage').submit();
    setTimeout("window.close()",2000);
    }
 else if (document.title.indexOf('Image:')==0 && location.href.indexOf('&fakeaction=ImagevandalRV&target=') !=-1)
  {
  var bad_user = unescape(location.href.split('&target=')[1]);
  var history_num = 1;
  var uls = document.getElementById('bodyContent').getElementsByTagName('ul');
  for (h=0; h<uls.length; h++)
  {
     if (uls[h].className == "special" && uls[h].innerHTML.indexOf('action=delete') !=-1)
     {history_num = h; break;}
  }
  var history = document.getElementById('bodyContent').getElementsByTagName('ul')[history_num].getElementsByTagName('li');
//check if he is the only contributor
  var Delete = 1;
  for (var i=0; i<history.length; i++)
      {
     if (history[i].innerHTML.indexOf('">' + bad_user + '</') == -1)
         {
        var RV_linkURL = history[i].getElementsByTagName('a')[1].href;
        Delete = 0;
        document.getElementById('contentSub').innerHTML = '<strong><span style="color:blue;">Reverting:</span> ' + RV_linkURL + '</strong>.';
        location.href = RV_linkURL;
        break;
         }
      }
//if they are the only contibutor
   if (Delete == 1)
    {
    var Delete_AllURL = history[0].getElementsByTagName('a')[0].href + '&fakeaction=ImageVandalDelete';
    document.getElementById('contentSub').innerHTML = '<strong><span style="color:red;">Deleting:</span> ' + Delete_AllURL + '</strong>.';
    location.href = Delete_AllURL;
    }
  }
 else if (document.title.indexOf('Confirm delete')==0 && location.href.indexOf('&fakeaction=ImageVandalDelete') !=-1)
  {
  document.getElementById('wpReason').value = 'Deleted bad faith uploads added by a vandal.';
  var form = document.getElementsByTagName('input')[1];
  form.click();
  }
//close JS action inputs
 else if (document.title.indexOf('Action complete')==0)
  {
  setTimeout('window.close()',1000);
  }
}
//////////////

//reverts edits
function masterroll()
{
  z=0;
  var oldloc = location.href;
  var message = "Are you sure you want to revert all top edits shown on this page by this user? Use this only to revert a large wave of vandalism by a single user or IP address." + "\n" + "To control how many edits this will revert, please set the number of articles on the list before performing this operation. You may also want to change the offset as well." + "\n" + "Close all other programs if there is a large number of edits to be reverted, otherwise, this may cause memory problems. Press OK to continue.";
  var return_value = confirm(message);
  if (return_value == true)
   {
    var password = prompt("Secondary confirmation:" + "\n" + "All top edits by this user will be reverted!" + "\n" + "Confirm type:");
     if (password == Rvaluejsadmin)
      {
    l = document.getElementById('bodyContent').getElementsByTagName('li');
    document.getElementById('contentSub').innerHTML = "<strong>All of the user's top edits are being reverted. This page will be refreshed automatically in 5 seconds</strong>.";
    for (i = 0; i < l.length; i++) 
      {
      var t = l[i].innerHTML;
      if (t.indexOf('<strong> (') != -1)
         {
        var article = l[i].getElementsByTagName('a')[0].href.split('&')[0].split('title=')[1].replace(/[^\/]*\/\/[^\/]*/, '');
        var li_a = l[i].getElementsByTagName('a');
        for (k = 3; k < li_a.length; k++)  
        {
        if (l[i].getElementsByTagName('a')[k].href.split('&action=rollback')[1] != undefined)
           {
z += 1;
var URL = l[i].getElementsByTagName('a')[k].href;
l[i].innerHTML += ' (' + vrollbacklink + ' )';
window.open(URL,'MasterrollJS' + z,'height=300,width=800,directories,resizeable');
        break;
           }    
         }
        }
      }
  }
        else
          {
         alert("Operation aborted.");
         return;
          }
 }
        else
          {
         alert("Operation aborted.");
         return;
          }
setTimeout("window.location.reload()",5000);
}
//

//rollback moves
function movemasterroll()
{
if (document.getElementById('bodyContent').getElementsByTagName('ul')[0] == undefined)
{alert('No page moves found.'); return;}
  var oldloc = location.href;
  var message = "Are you sure you want to revert all page moves by this user? Use this only to revert a large wave of vandalism by a single user or IP address." + "\n" + "To control how many moves this will revert, please set the number of articles on the list before performing this operation. You may also want to change the offset as well." + "\n" + "Close all other programs if there is a large number of moves to be reverted, otherwise, this may cause memory problems. Press OK to continue.";
  var return_value = confirm(message);
  if (return_value == true)
   {
    var Val_type = prompt("Secondary confirmation:" + "\n" + "All top moves by this user will be reverted!" + "\n" + "Confirm type:");
     if (Val_type == Mvaluejsadmin)
      {
    var c = document.getElementById('contentSub');
    var a = c.getElementsByTagName('a');
    l = document.getElementById('bodyContent').getElementsByTagName('li');
    document.getElementById('contentSub').innerHTML = "<strong>All of the user's top page moves are being reverted. This page will be refreshed automatically in 5 seconds</strong>.";
    for (i = 0; i < l.length; i++) 
      {
      var t = l[i].innerHTML;
      if (t.indexOf('moved') != -1)
        {
        var article = l[i].getElementsByTagName('a')[2].innerHTML;
        var li_a = l[i].getElementsByTagName('a');
        for (k = 2; k <li_a.length; k++) 
           {
            if (l[i].getElementsByTagName('a')[k].href.split('/w/index.php?title=Special:Movepage')[1] != undefined)
              {
              var URL = l[i].getElementsByTagName('a')[k].href + '&fakaction=masterfill';
              l[i].innerHTML += ' (' + vrollbacklink + ' )';
              window.open(URL,'MasterMoveRV' + article,'height=300,width=800,directories,resizeable');
              break;
              }    
           }
        }
   }
}
        else
          {
         alert("Operation aborted.");
         return;
          }
 }
        else
          {
         alert("Operation aborted.");
         return;
          }
setTimeout("window.location.reload()",5000);
}
//END

//reverts/deletes uploads
function masterdelete()
{
  var z = 0;
//are there any?
if (document.getElementById('bodyContent').getElementsByTagName('ul')[0] == undefined)
{alert('No file uploads found.'); return;}
  var oldloc = location.href;
  var message = "Are you sure you want to revert all uploads shown on this page by this user? Use this only to revert a large wave of vandalism by a single user or IP address. Uploads of which this user is the only author will be deleted." + "\n" + "To control how many uploads this will revert, please set the number of images on the list before performing this operation. You may also want to change the offset as well." + "\n" + "Close all other programs if there is a large number of edits to be reverted, otherwise, this may cause memory problems. Press OK to continue.";
  var return_value = confirm(message);
  if (return_value == true)
   {
   var Val_type = prompt("Secondary confirmation:" + "\n" + "All uploads by this user will be reverted!" + "\n" + "Confirm type:");
     if (Val_type == Uvaluejsadmin)
      {
    l = document.getElementById('bodyContent').getElementsByTagName('ul')[0].getElementsByTagName('li');
    var vandal = l[0].getElementsByTagName('a')[0].innerHTML;
    document.getElementById('contentSub').innerHTML = "<strong>All of the user's uploads are being reverted. This page will be refreshed automatically in 10 seconds</strong>.";
    for (i = 0; i < l.length; i++) 
      {
//check for non-deleted images
        var li_a = l[i].getElementsByTagName('a');
        for (k = 2; k <li_a.length; k++)  
        {
        if (l[i].getElementsByTagName('a')[k].innerHTML.indexOf('Image:') != -1 && l[i].getElementsByTagName('a')[k].href.indexOf('&action=edit') == -1)
             {
           z += 1;
           var URL = 'http://en.wikipedia.org/w/index.php?title=' + l[i].getElementsByTagName('a')[k].innerHTML;
           URL += '&fakeaction=ImagevandalRV&target=' + escape(vandal);
           l[i].innerHTML += ' (' + vrollbacklink + ' )';
           window.open(URL,'MasterrollImages' + z,'height=700,width=700,directories,resizeable,scrollbars');
           break;
             }    
         }
      }
  }
        else
          {
         alert("Operation aborted.");
         return;
          }
 }
        else
          {
         alert("Operation aborted.");
         return;
          }
setTimeout("window.location.reload()",10000);
}
//

//<pre><nowiki>

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

// -----------------------------------------------------------------------------
// POV rollback
// -----------------------------------------------------------------------------
var nrollbacklink = ' <strong><span style="color:black;">[</span><span style="color:darkblue;">rollback (AGF)</span><span style="color:black;">]</span> </strong></strong>';
var cantrollback = 'Cannot revert edit; last contributor is only author of this page.';
var alreadyrolled = 'Cannot rollback last edit of [[$1]] by [[User:$2|$2]] ([[User talk:$2|Talk]]); someone else has edited or rolled back the page already. Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]). ';
var nreverted_GML_sum = "Reverted [[WP:AGF|good faith]] edits by [[Special:Contributions/$2|$2]]. Don't be discouraged, just read up on our [[Wikipedia:Policies_and_guidelines|policies and guidelines]]. Thanks!";
//

// -----------------------------------------------------------------------------
// Vandal rollback
// -----------------------------------------------------------------------------
var vrollbacklink = '<span style="color:red;">reverting...</span>';
var rollbacklink = ' <span style="color:black;">[</span><span style="color:red;">rollback (vandal)</span><span style="color:black;">]</span><br></strong> ';
var cantrollback = 'Cannot revert edit; last contributor is only author of this page.';
var alreadyrolled = 'Cannot rollback last edit of [[$1]] by [[User:$2|$2]] ([[User talk:$2|Talk]]); someone else has edited or rolled back the page already. Last edit was by [[User:$3|$3]] ([[User talk:$3|Talk]]). ';
var revertpage_GML_sum = 'Reverted [[Wikipedia:Vandalism|vandalism]] by [[Special:Contributions/$2|$2]] to last version by $1. If you continue to compromise the integrity of pages you will be [[WP:BLOCK|blocked]] from editing.';
//

// -----------------------------------------------------------------------------
// Our nice Revert functions (vandal & POV)
// -----------------------------------------------------------------------------
var gml_vandal, gml_editor, gml_url;

function PerformRevert() 
{
  var l, token = '', revert = false, vandal = false;
  // Look for '&fakeaction=rollback' in URL
  gml_url = location.pathname;
  l = location.search.substring(1).split('&');
  for (i = 0; i < l.length; i++) {
    var n = l[i].indexOf('=');
    var name = l[i].substring(0, n);
    if (name == 'fakeaction') {
      if (l[i].substring(n + 1) == 'vandalrollback')
        {revert = true; vandal = true;}
      if (l[i].substring(n + 1) == 'normalrevert')
        {revert = true; vandal = false;}
    } else if (name == 'vandal') {
      gml_vandal = unescape(l[i].substring(n + 1));
    } else if (name == 'user') {
      gml_vandal = unescape(l[i].substring(n + 1));
    } else if (name == 'token') {
      token = unescape(l[i].substring(n + 1));
    } else if (name == 'title') {
      gml_url += '?' + l[i];
    }
  }
  if (!revert)
    return;
  if (vandal == true)
  {
  document.getElementById('bodyContent').innerHTML = '<strong>Please wait, reverting "vandal" edits by ' + gml_vandal + '...</strong>';
  }
  else if (vandal == false)
  {
  document.getElementById('bodyContent').innerHTML = '<strong>Please wait, reverting "Good Faith" edits by ' + gml_vandal + '...</strong>';
  }
  // Avoid XSS kiddies by using a special token
  if (token == '' || token != hex_md5(gml_url + escape(gml_vandal))) 
  {
    document.getElementById('bodyContent').innerHTML += '<br />Bad authentication token!';
    return;
  }
  gml_xmlhttp = HTTPClient();
  if (!gml_xmlhttp)
    return;
  history_url = gml_url + '&action=history&limit=12&useskin=none';
  document.getElementById('bodyContent').innerHTML += '<br /><span style="color:blue;">Getting article history (' + history_url + ')...</span>';
  gml_xmlhttp.open("GET", history_url, true);
  gml_xmlhttp.onreadystatechange = RevertStepTwo;
  gml_xmlhttp.send(null);
}

function RevertStepTwo() 
{
  if (gml_xmlhttp.readyState != 4)
    return;
  var l;
  var oldid;
  // Get the vandal and new editor names
  gml_editor = '';
  // Hack for a MediaWiki bug
  var bodyContent = document.getElementById('bodyContent');
  xml = parseXMLhack(gml_xmlhttp.responseText);
  xmlDoc = gml_XMLParse(xml);
  	if (!xmlDoc || !xmlDoc.firstChild)
		return bodyContent.innerHTML +=
		'<br />Failed to parse XML data returned by the server.' +
		'<br /><b>Hint: try to disable both "Enable section editing by right-clicking on section titles (JavaScript)" and "Edit pages on double click (JavaScript)" in your editing preferences until a proper fix is found<\/b>.'+ 
		'<br />Dump of the unparseable page : <br />' + xml.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
		// IE: added by Olliminatore 03.05.2006
	l = (IE)?xmlDoc.selectSingleNode('//*[@id="pagehistory"]').childNodes:
		xmlDoc.getElementById('pagehistory').getElementsByTagName('li');
	name = l[0].getElementsByTagName('span')[0].getElementsByTagName('a')[0].firstChild.nodeValue.replace(/_/g, ' ');
	if (name == gml_vandal)
        {
	       for (i = 1; i < l.length; i++)
               {
	    name = l[i].getElementsByTagName('span')[0].getElementsByTagName('a')[0].firstChild.nodeValue.replace(/_/g, ' ');
			if (name != gml_vandal)
                        {
			oldid = l[i].getElementsByTagName('input')[0].getAttribute('value');
			gml_editor = name;
			break;
			}
		}
        }
	else
		{return bodyContent.innerHTML += '<br />Error: Last editor is ' + name + ', not ' + gml_vandal + '!';}
	if (gml_editor == '')
		{return bodyContent.innerHTML += '<br />Error: ' + gml_vandal + ' is the only editor!';}
  gml_xmlhttp = HTTPClient();
  if (!gml_xmlhttp)
    return;
  document.getElementById('bodyContent').innerHTML += '<br /><span style="color:blue;">Getting article edit form (GET' + gml_url + '&action=edit&oldid=' + oldid + '&useskin=none' + ')...</span>';
  gml_xmlhttp.open('GET', gml_url + '&action=edit&oldid=' + oldid + '&useskin=none', true);
  gml_xmlhttp.onreadystatechange = RevertStepThree;
  gml_xmlhttp.send(null);
}

function RevertStepThree() 
{
  if (gml_xmlhttp.readyState != 4)
  {return;}
  vandal = false;
  if (location.href.indexOf('=vandalrollback') != -1)
  {vandal = true;}
  var form, newform, l;
  var artname = document.title.split('Editing ')[1].split(' - ')[0];
  // Insert the downloaded form in our current page, using
  // only hidden form inputs.
	// IE: added by Olliminatore 03.05.2006
        var xml = gml_xmlhttp.responseText;
	xmlDoc = standard_XMLParse(xml);
	form = (IE)? xmlDoc.selectSingleNode('//*[@id="editform"]') :
		xmlDoc.getElementById('editform');
	l = form.getElementsByTagName('textarea');
	newform = document.createElement('form');
	for (i = l.length; i--;){
		var t = document.createElement('input');
		t.type = 'hidden',
		t.name = l[i].getAttribute('name');
		t.value = (IE)?l[i].nodeTypedValue:l[i].value;  //nodeValue don't work for FF
		newform.appendChild(t)
	}
	l = form.getElementsByTagName('input');
	for (i = l.length; i--;){
	liname = l[i].getAttribute('name');
		if (liname == 'wpSummary')
		{
                  if (vandal == true)
                     {l[i].setAttribute('value', revertpage_GML_sum.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal));}
                  else
                     {l[i].setAttribute('value', nreverted_GML_sum.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal));}
                }
		else if (liname == 'wpMinoredit') {l[i].setAttribute('value', '1');}
		else if (liname == 'wpWatchthis')
                {
			if (!l[i].getAttribute('checked')) continue; // Don’t touch the "watch" status
			l[i].setAttribute('value', "on")
                }
    else if (liname == 'wpPreview' || liname == 'wpDiff') continue;
		l[i].setAttribute('type', 'hidden');
		if (IE) newform.insertAdjacentHTML('beforeEnd', l[i].xml);
		else newform.appendChild(l[i]);
	}
	newform.style.visibility='hidden'; // not really needed
	newform.name = form.getAttribute('name');
	newform.method = form.getAttribute('method');
	newform.id = form.getAttribute('id');
	newform.action = form.getAttribute('action');
        var bodyContent = document.getElementById('bodyContent');
	bodyContent.innerHTML += '<br /><strong>Submitting form...</strong>';
	bodyContent.appendChild(newform);
  if (vandal == true)
  {
  var name = 'targetnameRV:' + artname;
  window.open('http://en.wikipedia.org/w/index.php?title=User talk:' + gml_vandal + '&action=edit&vanarticle=' + escape(artname),'targetnameRV','height=800,width=800,location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
  }
  // Submit the form
  newform.submit();
}
//

// -----------------------------------------------------------------------------
// XMLHttpRequest support
// -----------------------------------------------------------------------------
var IE=(window.ActiveXObject)?true:false;

function parseXMLhack(xml)
{  // fixed: Hack for a MediaWiki bugs
	xml = xml.replace(/<body .*\"ns-(.*)\">/, '<body class="ns-$1">');
	rer = xml.match(/<h1 .*<\/h1>/)[0].replace(/&/g, '&amp;');
	if (rer) xml = xml.replace(/<h1 .*<\/h1>/, rer);
	return xml
}

function gml_XMLParse(string)
{
	if (document.implementation.createDocument)
		return gml_xmlparser.parseFromString(string, "text/xml");
	else if (IE)
               {
		var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
		gml_xmldoc.async = false;
		ret = gml_xmldoc.loadXML(string);
		myErr = gml_xmldoc.parseError;
		if (myErr.errorCode || !ret){
			showError("Error: " + ERROR_XML + myErr.reason);
			return null;
		}
		return gml_xmldoc.documentElement
	}
	return null
}

if (document.implementation.createDocument)
 {var gml_xmlparser = new DOMParser();}

function standard_XMLParse(string) 
{
  if (document.implementation.createDocument)
 {
    return gml_xmlparser.parseFromString(string, "text/xml");
  } 
  else if (window.ActiveXObject) 
  {
    string = string.replace(/<body .*\"ns-(.*)\">/, '<body class="ns-$1">');
    rer = string.match(/<h1 .*<\/h1>/)[0].replace(/&/g, '&');
    if (rer) {string = string.replace(/<h1 .*<\/h1>/, rer);}
    var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM");
    gml_xmldoc.async = false;
    ret = gml_xmldoc.loadXML(string);
    myErr = gml_xmldoc.parseError;
		if (myErr.errorCode || !ret)
                {
			showError("Error: " + ERROR_XML + myErr.reason);
			return null;
		}
		return gml_xmldoc.documentElement
  }
  return null;
}

var gml_xmlhttp;

function HTTPClient()
{
  var gml_http = false;
  if(window.XMLHttpRequest)
    gml_http = new XMLHttpRequest();
  else if (IE){
    try{
      gml_http = new ActiveXObject("Msxml2.XMLHTTP")
    } catch (e){
      try{
        gml_http = new ActiveXObject("Microsoft.XMLHTTP")
      } catch (e){}
    }
  }
	if (!gml_http) showError(ERROR_XML);
  return gml_http
};


// -----------------------------------------------------------------------------
// MD5 hash calculator
// -----------------------------------------------------------------------------
// Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
// Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
// Distributed under the BSD License
// See http://pajhome.org.uk/crypt/md5 for more info.
// -----------------------------------------------------------------------------
var hexcase = 0;
var b64pad  = "";
var chrsz   = 8;

function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}

function core_md5(x, len)
{
  x[len >> 5] |= 0x80 << ((len) % 32);
  x[(((len + 64) >>> 9) << 4) + 14] = len;

  var a =  1732584193;
  var b = -271733879;
  var c = -1732584194;
  var d =  271733878;

  for(var i = 0; i < x.length; i += 16)
  {
    var olda = a;
    var oldb = b;
    var oldc = c;
    var oldd = d;

    a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936); d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586); c = md5_ff(c, d, a, b, x[i+ 2], 17,  606105819); b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330); a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897); d = md5_ff(d, a, b, c, x[i+ 5], 12,  1200080426); c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341); b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983); a = md5_ff(a, b, c, d, x[i+ 8], 7 ,  1770035416); d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417); c = md5_ff(c, d, a, b, x[i+10], 17, -42063); b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162); a = md5_ff(a, b, c, d, x[i+12], 7 ,  1804603682); d = md5_ff(d, a, b, c, x[i+13], 12, -40341101); c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290); b = md5_ff(b, c, d, a, x[i+15], 22,  1236535329);

    a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510); d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632); c = md5_gg(c, d, a, b, x[i+11], 14,  643717713); b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302); a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691); d = md5_gg(d, a, b, c, x[i+10], 9 ,  38016083); c = md5_gg(c, d, a, b, x[i+15], 14, -660478335); b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848); a = md5_gg(a, b, c, d, x[i+ 9], 5 ,  568446438); d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690); c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961); b = md5_gg(b, c, d, a, x[i+ 8], 20,  1163531501); a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467); d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784); c = md5_gg(c, d, a, b, x[i+ 7], 14,  1735328473); b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);

    a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558); d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463); c = md5_hh(c, d, a, b, x[i+11], 16,  1839030562); b = md5_hh(b, c, d, a, x[i+14], 23, -35309556); a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060); d = md5_hh(d, a, b, c, x[i+ 4], 11,  1272893353); c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632); b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640); a = md5_hh(a, b, c, d, x[i+13], 4 ,  681279174); d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222); c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979); b = md5_hh(b, c, d, a, x[i+ 6], 23,  76029189); a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487); d = md5_hh(d, a, b, c, x[i+12], 11, -421815835); c = md5_hh(c, d, a, b, x[i+15], 16,  530742520); b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);

    a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844); d = md5_ii(d, a, b, c, x[i+ 7], 10,  1126891415); c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905); b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055); a = md5_ii(a, b, c, d, x[i+12], 6 ,  1700485571); d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606); c = md5_ii(c, d, a, b, x[i+10], 15, -1051523); b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799); a = md5_ii(a, b, c, d, x[i+ 8], 6 ,  1873313359); d = md5_ii(d, a, b, c, x[i+15], 10, -30611744); c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380); b = md5_ii(b, c, d, a, x[i+13], 21,  1309151649); a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070); d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379); c = md5_ii(c, d, a, b, x[i+ 2], 15,  718787259); b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);

    a = safe_add(a, olda);
    b = safe_add(b, oldb);
    c = safe_add(c, oldc);
    d = safe_add(d, oldd);
  }
  return Array(a, b, c, d);

}

function md5_cmn(q, a, b, x, s, t) { return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b); }
function md5_ff(a, b, c, d, x, s, t) { return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t); }
function md5_gg(a, b, c, d, x, s, t) { return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t); }
function md5_hh(a, b, c, d, x, s, t) { return md5_cmn(b ^ c ^ d, a, b, x, s, t); }
function md5_ii(a, b, c, d, x, s, t) { return md5_cmn(c ^ (b | (~d)), a, b, x, s, t); }

function safe_add(x, y)
{
  var lsw = (x & 0xFFFF) + (y & 0xFFFF);
  var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
  return (msw << 16) | (lsw & 0xFFFF);
}

function bit_rol(num, cnt)
{
  return (num << cnt) | (num >>> (32 - cnt));
}

function str2binl(str)
{
  var bin = Array();
  var mask = (1 << chrsz) - 1;
  for(var i = 0; i < str.length * chrsz; i += chrsz)
    bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
  return bin;
}

function binl2hex(binarray)
{
  var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
  var str = "";
  for(var i = 0; i < binarray.length * 4; i++)
  {
    str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
           hex_tab.charAt((binarray[i>>2] >> ((i%4)*8  )) & 0xF);
  }
  return str;
}
// -----------------------------------------------------------------------------
// Add revert buttons to the page (vandal rollback)
// -----------------------------------------------------------------------------
addOnloadHook(AddRevertButtonsnorm)
function AddRevertButtonsnorm() {
  var l, article = '', vandal;
 // Add 'revert' links to a diff page [[Category:VoA scripted admins]]
  var user_name = document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML;
  l = document.getElementById('bodyContent').getElementsByTagName('td');
  for (i = 0; i < l.length; i++) {
    if (l[i].className == 'diff-otitle') {
      if (!l[i].getElementsByTagName('a')[0]){return;}
      article = l[i].getElementsByTagName('a')[0].href.split('&')[0].replace(/[^\/]*\/\/[^\/]*/, '');
    } else if (l[i].className == 'diff-ntitle') {
      var toplink = l[i].getElementsByTagName('a')[0].href;
      vandal = escape(l[i].getElementsByTagName('a')[2].innerHTML);
      IEvandal = escape(l[i].getElementsByTagName('a')[2].innerHTML);
      var t = l[i].innerHTML;
      n = t.indexOf('</a>) <br') + t.indexOf('</A>) <BR') + 1; // XXX: WOW HACK!!!!
      if (article != '' && toplink.indexOf('oldid=') == -1) 
      {
        l[i].innerHTML = t.substring(0, n + 5) + ' &nbsp;&nbsp;&nbsp; <strong><a href="' + article.replace(/&/g,"%26") + '&action=edit&fakeaction=normalrevert&user=' + vandal + '&token=' + hex_md5(article + vandal) + '">' + nrollbacklink + '</a> || <strong><a href="' + article.replace(/&/g,"%26") + '&action=edit&fakeaction=vandalrollback&vandal=' + vandal + '&token=' + hex_md5(article + vandal) + '">' + rollbacklink + '</a> ' + t.substring(n + 9, t.length);
      }
    }
  }
}
////////////

////////////Backlog bar////////////
function adminbacklog()
{
  if (window.ActiveXObject){return;}
  if (document.title.search(/(User:|User talk:|Talk:|Editing )/) == 0){return;}
  gml_xmlhttp = HTTPClient();
  if (!gml_xmlhttp)
    return;
  var pageurl = 'http://en.wikipedia.org/w/index.php?title=Special:Whatlinkshere&target=Template%3AAdminbacklog&useskin=none';
  gml_xmlhttp.open("GET", pageurl, true);
  gml_xmlhttp.onreadystatechange = adminbacklogbar;
  gml_xmlhttp.send(null);
}
//

//
function adminbacklogbar()
{
  if (gml_xmlhttp.readyState != 4)
    return;
  xml = gml_xmlhttp.responseText.split('Retrieved from "<a href=')[0].split('Retrieved from "<A href=')[0].split('The following pages link to here:')[1];
  var links = xml.split('" title="');
  var backlog = '';
for (i=0; i<links.length; i++)
  {
  var name = links[i].split('">')[0];
  if (name.search('(/|:Images on|:Images with|:Suspected)') == -1 && links[i].split('</li>')[0].indexOf('(transclusion)') != -1 && (name.indexOf('Wikipedia:') != -1 || name.indexOf('Category:') != -1))
  {backlog += ', <a href="/wiki/' + name + '" title="' + name + '">' + name.replace('Wikipedia:','').replace('Category:','') + '</a>';}
  }
backlog = backlog.replace(', ','');
if (backlog != '')
  {
  var message = '<div style="align: center; padding: .4em; font-size:9pt;">' + '<span style="color: darkred"><strong>Administrator backlogs:</span></strong> ' + backlog + '</div>';
  var csub=document.getElementById("top");
  var msg=document.createElement("alog");
  msg.innerHTML = message;
  msg.className="backlog";
  csub.insertBefore(msg, csub.firstChild)
  }
}
////////////

////////////Wikipedia:WikiProject User scripts/Scripts/RBL check////////////
// This script adds an "[[DNSBL|RBL]] check" link to the toolbox on IP user/talk/contribs pages.  <pre><nowiki>

addOnloadHook(function () {
    var href = document.getElementById('t-contributions');
    if (href) href = href.getElementsByTagName('a');
    if (href) href = href[0];
    if (href) href = href.href;
    else href = window.location.href;

    var addr = /(\/wiki\/|[?&]title=)Special:Contributions(\/([^\/?&#]*)|[?&#]|$)/.exec(href);
    if (!addr) return;
    addr = addr[3];
    if (!addr) {
        addr = /^[^?#]*\?([^&#]*&)*target=([^&#]*)/.exec(href);
        if (!addr) return;
        addr = addr[2];
    }
    if (!/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/.test(addr)) return;

    addLink('p-tb', 'http://www.robtex.com/rbls/'+addr+'.html', 'RBL check', 't-rblcheck', 'Multi-RBL check', null, 't-contributions');
});
////////////

////////////////"Images with the same name on Wikimedia Commons" stuff////////////////
addOnloadHook(ImageJSdelete)
function ImageJSdelete()
{
if (document.title.indexOf('Category:Images with the same name on Wikimedia Commons')==0)
  {
  addTab("javascript:imagescript()", "Compare", "ca-catlgl", "Compare Licenses", "");
  addTab("javascript:imagescript_auto()", "Auto", "ca-catlau", "Compare and auto-delete", "");
  }
else if (document.title.indexOf('Confirm delete')==0 && location.href.indexOf('&fakeaction=JScommonsIMGreplace') !=-1)
  {
  document.getElementById('wpReason').value = 'Image exists on Commons with the same name, history, and a compatible license.';
  var form = document.getElementsByTagName('input')[1];
  form.click();
  setTimeout('form.click()',5000);
  }
if (document.title.indexOf('Action complete')==0)
  {
  setTimeout('window.close()',1000);
  }
}
//

//globals
auto_delete_catON = 0;
divsec_js = 0;
div_cat_jsnumber = 0;
//

function imagescript_auto()
{
 auto_delete_catON = 1;
 var tables = document.getElementsByTagName('table');
 for (var i=0; i<tables.length; i++)
    {
      if (tables[i].className == 'gallery')
      {divsec_js = i; break;}
    }
 if (divsec_js==0){return;}
 imagescript_add();
}

function imagescript()
{
 auto_delete_catON = 0;
 var tables = document.getElementsByTagName('table');
 for (var i=0; i<tables.length; i++)
    {
      if (tables[i].className == 'gallery')
      {divsec_js = i; break;}
    }
 if (divsec_js==0){return;}
 imagescript_add();
}

function imagescript_add()
{
 var gallery = document.getElementsByTagName('table')[divsec_js].getElementsByTagName('td');
 if (div_cat_jsnumber==gallery.length){return;}
 var URL = 'http://en.wikipedia.org/w/index.php?title=Image:' + gallery[div_cat_jsnumber].getElementsByTagName('a')[0].href.split('/wiki/Image:')[1] + '&action=edit';
 gml_xmlhttp = HTTPClient();
 //if (!gml_xmlhttp){setTimeout('imagescript_add()',50);}
 gml_xmlhttp.open("GET", URL, true);
 gml_xmlhttp.onreadystatechange = div_addCATlinks_COMMONS;
 gml_xmlhttp.send(null);
}

//globals
XML_cat_jsglobalEN = '';
XML_cat_jsglobalCOMMONS = '';
//

function div_addCATlinks_COMMONS()
{
if (!gml_xmlhttp){return;}
if (gml_xmlhttp.readyState != 4){return;}
XML_cat_jsglobalEN = gml_xmlhttp.responseText;
//
 var gallery = document.getElementsByTagName('table')[divsec_js].getElementsByTagName('td');
 var URL = 'http://commons.wikimedia.org/w/index.php?title=Image:' + gallery[div_cat_jsnumber].getElementsByTagName('a')[0].href.split('/wiki/Image:')[1] + '&action=edit';
//
try {netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");} 
catch (e) {alert("Permission UniversalBrowserRead denied.");} 
http_request = false;
http_request = new XMLHttpRequest(); 
//if (!http_request){setTimeout('div_addCATlinks_COMMONS()',50);}
if (http_request.overrideMimeType) 
{http_request.overrideMimeType('text/xml');}
if (!http_request) 
{alert('Cannot create XMLHTTP instance'); return;} 
http_request.onreadystatechange = div_addCATlinks;
http_request.open('GET', URL, true); 
http_request.send(null); 
}

//
function div_addCATlinks()
{
if (!http_request){return;}
if (http_request.readyState != 4){return;}
XML_cat_jsglobalCOMMONS = http_request.responseText;
//
var gallery = document.getElementsByTagName('table')[divsec_js].getElementsByTagName('td')[div_cat_jsnumber];
var gallerys = document.getElementsByTagName('table')[divsec_js].getElementsByTagName('td');
var IMAGE_NAME = gallerys[div_cat_jsnumber].getElementsByTagName('a')[1].innerHTML;
var URL_EN = 'http://en.wikipedia.org/w/index.php?title=Image:' + gallerys[div_cat_jsnumber].getElementsByTagName('a')[0].href.split('/wiki/Image:')[1];
var URL_C = 'http://commons.wikimedia.org/w/index.php?title=Image:' + gallerys[div_cat_jsnumber].getElementsByTagName('a')[0].href.split('/wiki/Image:')[1];
//Add DELETE functions
gallery.innerHTML += '<span class="popup" onClick=javascript:window.open("' + URL_EN + '&action=delete&fakeaction=JScommonsIMGreplace","blank","height=700,width=900,scrollbars=yes")><p style="cursor:pointer"><b><span style="color: black">[</span><span style="color: red">delete</span><span style="color: black">] </span></b></p></span>';
//
//edit mode text EN
XML_cat_jsglobalEN = XML_cat_jsglobalEN.split('</textarea>')[0].split('<textarea')[1];
XML_cat_jsglobalEN = XML_cat_jsglobalEN.replace(/\{\{NowCommons(This)\}\}/i,'').replace(/\{\{NCT\}\}/i,'');
XML_cat_jsglobalEN = XML_cat_jsglobalEN.replace(/\{\{[C]cite/g,'').replace(/\{\{..\}\}/g,'').replace(/\{\{[Ii]nformation/g,'');
//
var templates = '';
var templates_typeEN = '';
var temp_lic = XML_cat_jsglobalEN.split('{{');
for (var i=1; i<temp_lic.length; i++)
    {
    var license = temp_lic[i].split('}}')[0].split('|')[0];
    templates_typeEN += '{{' + license.split('-')[0] + '}}';
    if (i==1)
    {templates += '{{' + license + '}}';}
    else
    {templates += '<br>' + '{{' + license + '}}';}
    }
if (templates == '')
{templates += '(other/none)';}
gallery.innerHTML += '<span class="popup" onClick=javascript:window.open("' + URL_EN + '","blank","height=700,width=900,scrollbars=yes")><p style="cursor:pointer"><b><span style="color: darkblue">Wikipedia:</span></b></p></span>' + templates;
//
//edit mode text COMMONS
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.split('</textarea>')[0].split('<textarea')[1];
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{NowCommons(This)\}\}/i,'').replace(/\{\{NCT\}\}/i,'');
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{[C]cite/g,'').replace(/\{\{..\}\}/g,'').replace(/\{\{[Ii]nformation/g,'');
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{[Ee]n-/g,'').replace(/\{\{[Dd]e-/g,'').replace(/\{\{[Ff]r-/g,'').replace(/\{\{[Jj]p-/g,'').replace(/\{\{[Ee]nglish/g,'').replace(/\{\{[Gg]erman/g,'').replace(/\{\{[Ff]rench/g,'');
templates = '';
var templates_typeC = '';
temp_lic = XML_cat_jsglobalCOMMONS.split('{{');
for (var i=1; i<temp_lic.length; i++)
    {
    var license = temp_lic[i].split('}}')[0].split('|')[0];
    templates_typeC += '{{' + license.split('-')[0] + '}}';
    if (i==1)
    {templates += '{{' + license + '}}';}
    else
    {templates += '<br>' + '{{' + license + '}}';}
    }
if (templates == '')
{templates += '(other/none)';}
var name_no_namespace = IMAGE_NAME.replace('Image:','');
if (templates_typeEN == templates_typeC && templates_typeEN.search('[Ff]featured') == -1 && templates_typeEN.indexOf('(other/none)') == -1 && auto_delete_catON ==1 && name_no_namespace.length >= 12)
  {
  window.open(URL_EN + '&action=delete&fakeaction=JScommonsIMGreplace',
              'targetnamedel' + IMAGE_NAME,
  'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
  }
else if (templates_typeC.search('\\{\\{(GFDL|gfdl|PD|Pd-)') != -1 && templates_typeEN.search('[Ff]featured') == -1 && name_no_namespace.length >= 12 && auto_delete_catON ==1)
  {
  window.open(URL_EN + '&action=delete&fakeaction=JScommonsIMGreplace',
              'targetnamedel' + IMAGE_NAME,
  'location=no,toolbar=no,status=no,directories=no,scrollbars=yes,fullscreen=yes');
  }
gallery.innerHTML += '<span class="popup" onClick=javascript:window.open("' + URL_C + '","blank","height=700,width=900,scrollbars=yes")><p style="cursor:pointer"><b><span style="color: darkred">Commons:</span></b></p></span>' + templates;
//
div_cat_jsnumber+=1;
imagescript_add();
}
////////////////

/////////////////////////////////IP range contribs check/////////////////////////////////
//globals
var starting_IP_trunk = '';
var starting_IP_end = 0;
var IP_num_JS_count = 0;
var IP_num_JS_static = 0;
//

addOnloadHook(IPRange_contribs_tab)
function IPRange_contribs_tab()
{
if (location.href.search(/Special(:|%3A)Contributions/) != -1 && location.href.search(/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/) != -1 && location.href.search(/\d{1,3}(@|%40)\d{1,2}/) == -1)
  {
  addTab("javascript:IPRange_contribs_query()", "Range", "ca-range", "Check a range", "");
  }
}

function IPRange_contribs_query()
{
if (location.href.indexOf('/Special:Contributions/') != -1)
{var IP = location.href.split('/Special:Contributions/')[1];}
else
{var IP = location.href.split('&target=')[1].split('&')[0];}
var number = prompt('Number of consecutive IPs?' + '\n' + '(/24 bit check or less.)');
if (!number){return;}
location.href = 'http://en.wikipedia.org/w/index.php?&limit=1&target=' + IP + '@' + number + '&title=Special%3AContributions&namespace=';
}

function IPRange_contribs()
{
if (location.href.search(/title=Special:Contributions&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@\d{1,2}/) != -1)
  {
  var target = location.href.split('&target=')[1];
  var static_IP_mark = target.split('.')[3];
  starting_IP_trunk = target.split(static_IP_mark)[0];
  var ending_num = target.split('@')[1];
  starting_IP_end = target.split('.')[3].split('@')[0];
//
  var IP_end_last_show = 1*starting_IP_end + 1*ending_num;
  var IP_start_show = starting_IP_trunk + starting_IP_end;
  var IP_last_show = starting_IP_trunk + IP_end_last_show;
  document.getElementById('bodyContent').innerHTML = document.getElementById('bodyContent').innerHTML.replace('No changes were found matching these criteria.','');
  document.getElementById('siteSub').innerHTML += "<br><strong>Checking IP range contributions from <span style='color: darkblue'>" + IP_start_show + "</span> to <span style='color: darkblue'>" + IP_last_show + "</span></strong>:";
  IPRange_contribs_XML();
  }
else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}%40\d{1,2}/) != -1 && location.href.indexOf('&title=Special%3AContributions') != -1)
  {
  var target = location.href.split('&target=')[1].split('&')[0];
  var static_IP_mark = target.split('.')[3];
  starting_IP_trunk = target.split(static_IP_mark)[0];
  var ending_num = target.split('%40')[1];
  starting_IP_end = target.split('.')[3].split('%40')[0];
//
  var IP_end_last_show = 1*starting_IP_end + 1*ending_num;
  var IP_start_show = starting_IP_trunk + starting_IP_end;
  var IP_last_show = starting_IP_trunk + IP_end_last_show;
  document.getElementById('bodyContent').innerHTML = document.getElementById('bodyContent').innerHTML.replace('No changes were found matching these criteria.','');
  document.getElementById('siteSub').innerHTML += "<br><strong>Checking IP range contributions from <span style='color: darkblue'>" + IP_start_show + "</span> to <span style='color: darkblue'>" + IP_last_show + "</span></strong>:";
  IPRange_contribs_XML();
  }
//
else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}@\d{1,2}/) != -1 && location.href.indexOf('&title=Special%3AContributions') != -1)
  {
  document.getElementById('siteSub').innerHTML += '<br><strong>Select a namespace and press "Go" to check contribtutions from this IP range. This will only check back 20 edits however.</strong>';
  }
else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}.\d{2}@\d{1,2}/) != -1)
  {
location.href = location.href.replace(/.\d{2}@/,'@');
  }
else if (location.href.search(/&target=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}%40\d{1,2}/) != -1) 
  {
location.href = location.href.replace(/.\d{2}%40/,'%40');
  }
}

function IPRange_contribs_XML()
{
  var namespace = '&namespace=';
  if (location.href.search(/&namespace=\d/) != -1)
  {namespace = '&namespace=' + location.href.split('&namespace=')[1].split('&')[0];}
  var target = location.href.split('&target=')[1].split('&')[0];
  if (target.indexOf('@') != -1)
  {var ending_num = target.split('@')[1];}
  else if (target.indexOf('%40') != -1)
  {var ending_num = target.split('%40')[1];}
  var current_num = 1*starting_IP_end + 1*IP_num_JS_count;
  if (IP_num_JS_count > ending_num)
  {
  document.getElementById('contentSub').innerHTML = "<strong>Done:<span style='color: blue'> edits retrieved.</span></strong>";
  edits_page_compared_js = 1;
  addTab("javascript:compare_contribs_range()", "Compare", "ca-comp", "Compare", "");
  var body = document.getElementById('bodyContent');
  body.ranSetupTooltipsAlready=false;
  setupTooltips(body);
  return;
  }
  if (current_num > 255)
  {
  document.getElementById('contentSub').innerHTML = "<strong><span style='color: darkred'>IP bloc number exceeds 255, query stopped!</span></strong>";
  edits_page_compared_js = 1;
  var body = document.getElementById('bodyContent');
  addTab("javascript:compare_contribs_range()", "Compare", "ca-comp", "Compare", "");
  body.ranSetupTooltipsAlready=false;
  setupTooltips(body);
  return;
  }
  if (location.href.indexOf('Special:Contributions&target=') != -1)
  {
  var URL = location.href.split('Special:Contributions&target=')[0] + 'Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=20';
  }
  else
  {
  var URL = 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=20&useskin=none';
  }
  document.getElementById('contentSub').innerHTML = "<strong>Checking: " + starting_IP_trunk + current_num + "</strong>";
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_contribs_xml;
  gml_http.send(null);
}

function parse_contribs_xml()
{
  if (gml_http.readyState != 4)
  {return;}
  xml = gml_http.responseText;
  if (xml.indexOf('No changes were found matching these criteria.') == -1)
  {
  var contribs = xml.split('<ul>')[1].split('</ul>')[0];
  var current_num = 1*starting_IP_end + 1*IP_num_JS_count;
  document.getElementById('bodyContent').innerHTML += '<p><strong>' + starting_IP_trunk + current_num + '</strong></p>' + '<ul>' + contribs + '</ul>';
  }
  IP_num_JS_count += 1;
  IPRange_contribs_XML();
}
/////////////////////////////////

////////////////////Compare contribs////////////////////
addOnloadHook(Compare_tab_add)
function Compare_tab_add()
{
if (document.title.indexOf('User contributions') == 0 && location.href.search(/\d{1,3}(@|%40)\d{1,2}/) == -1)
{addTab("javascript:compare_contribs()", "Compare", "ca-comp", "Compare", "");}
}

//globals
username_contribs_comp = '';
username_contribs_comp2 = '';
//
function compare_contribs()
{
username_contribs_comp2 = prompt('Compare with who?' + '\n' + '*for last 1000 edits' + '\n' + '*selected namespace' + '\n' + '*for last 15 (un)blocks');
if (!username_contribs_comp2){return;}
username_contribs_comp = document.getElementById('contentSub').getElementsByTagName('a')[0].innerHTML;
if (username_contribs_comp == 'Talk' && location.href.indexOf('&target=') != -1)
{username_contribs_comp = location.href.split('&target=')[1].split('&')[0];}
else if (username_contribs_comp == 'Talk' && location.href.indexOf('/Special:Contributions/') != -1)
{username_contribs_comp = location.href.split('/Special:Contributions/')[1];}
if (username_contribs_comp == username_contribs_comp2){alert('Cannot compare a user with his/herself!'); return;}
  document.getElementById('contentSub').innerHTML += "<br><strong>Requesting block log and contribs XML for users...</strong>";
  var namespace = '';
//get namespace
  if (document.getElementById('namespace'))
    {
    var inputs = document.getElementById('namespace').getElementsByTagName('option');
    for (i=0; i<inputs.length; i++)
       {
       if (inputs[i].selected==true)
          {var namespace = '&namespace=' + inputs[i].value; break;}
       }
    } 
//
  var URL = 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + username_contribs_comp + namespace + '&limit=1000&useskin=none';
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_xml_contribs2;
  gml_http.send(null);
}

function parse_xml_contribs2()
{
  if (gml_http.readyState != 4)
  {return;}
  doc1_xml_contribs_xml = gml_http.responseText;
  var namespace = '';
//get namespace
  if (document.getElementById('namespace'))
    {
    var inputs = document.getElementById('namespace').getElementsByTagName('option');
    for (i=0; i<inputs.length; i++)
       {
       if (inputs[i].selected==true)
          {var namespace = '&namespace=' + inputs[i].value; break;}
       }
    } 
//
  var URL = 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + username_contribs_comp2 + namespace + '&limit=1000&useskin=none';
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_xml_comparecontribs_log;
  gml_http.send(null);
}

function compare_contribs_range()
{
username_contribs_comp2 = prompt('Compare with who?' + '\n' + '*for last 1000 edits' + '\n' + '*all namespaces');
if (!username_contribs_comp2){return;}
username_contribs_comp = 'Selected IP range';
  document.getElementById('contentSub').innerHTML += "<br><strong>Requesting block log and contribs XML for users...</strong>";
  var URL = 'http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + username_contribs_comp2 + '&limit=1000&useskin=none';
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_xml_contribs_range;
  gml_http.send(null);
}

//cache
doc_js_ipcontribs_range_cache = '';
//
function parse_xml_contribs_range()
{
  if (gml_http.readyState != 4)
  {return;}
  xml = gml_http.responseText;
  var doc2 = standard_XMLParse(xml);
  if (doc_js_ipcontribs_range_cache == '')
  {
  var doc1 = document;
  doc_js_ipcontribs_range_cache = document;
  }
  else
  {var doc1 = doc_js_ipcontribs_range_cache;}
  var l = doc1.getElementsByTagName('li');
  var name_list = '||';
  var list_common = '||';
  for (i=0; i<l.length; i++)
  {
    if (l[i].getElementsByTagName('a')[2] != undefined)
    {
    var name = l[i].getElementsByTagName('a')[2].innerHTML;
    name_list += name + '||';
    }
  }
  if (doc2.getElementsByTagName('ul')[0] != undefined)
  {
  var h = doc2.getElementsByTagName('ul')[0].getElementsByTagName('li');
     for (i=0; i<h.length; i++)
     {
     var name = h[i].getElementsByTagName('a')[2].innerHTML;
     if (name_list.indexOf('||' + name + '||') != -1 && list_common.indexOf('||' + name + '||') == -1)
     {list_common += name + '||';}
     }
  }
//
  if (list_common == '||' || doc2.getElementsByTagName('ul')[0] == undefined)
  {
  document.getElementById('contentSub').innerHTML += "<br><strong>Done:<span style='color: blue'> comparison between edits by </span>" + username_contribs_comp + " <span style='color: blue'>and</span> " + username_contribs_comp2 + " <span style='color: blue'>finished.</span> (no matches)</strong>";
  var uls = document.getElementById('bodyContent').getElementsByTagName('ul');
  for (i=0; i<uls.length; i++)
     {
     uls[i].innerHTML = '';
     }
  var ps = document.getElementById('bodyContent').getElementsByTagName('p');
  for (i=0; i<ps.length; i++)
     {
     ps[i].innerHTML = '';
     }
  return;
  }
//
  var txt_add = '';
  var common_names = list_common.split('||');
  for (i=1; i< common_names.length-1; i++)
  {
  var pgname = common_names[i];
  var pglink = '<a href="/wiki/' + pgname + '" title="' + pgname + '">' + pgname + '</a>'; 
  txt_add += "<p><strong>Page: " + pglink + "</strong></p><span style='color: purple'><p><strong>" + username_contribs_comp2 + "</strong></p></span><ul>";
     for (k=0; k<h.length; k++)
      {
      var name = h[k].getElementsByTagName('a')[2].innerHTML;
       if (name == pgname)
       {txt_add += '<li>' + h[k].innerHTML + '</li>';}
      }
   txt_add += "</ul><p><span style='color: darkred'><strong>" + username_contribs_comp + "</strong></span></p><ul>";
     for (k=0; k<l.length; k++)
      {
      if (l[k].getElementsByTagName('a')[2] != undefined)
        {
         var name = l[k].getElementsByTagName('a')[2].innerHTML;
         if (name == pgname)
         {txt_add += '<li>' + l[k].innerHTML + '</li>';}
        }
      }
      txt_add += '</ul>'
   }
//
  document.getElementById('contentSub').innerHTML += "<br><strong>Done:<span style='color: blue'> comparison between edits by </span>" + username_contribs_comp + " <span style='color: blue'>and</span> " + username_contribs_comp2 + " <span style='color: blue'>finished.</span></strong>";
  document.getElementById('bodyContent').getElementsByTagName('ul')[0].innerHTML = '';
  var uls = document.getElementById('bodyContent').getElementsByTagName('ul');
  for (i=0; i<uls.length; i++)
     {
     uls[i].innerHTML = '';
     }
  var ps = document.getElementById('bodyContent').getElementsByTagName('p');
  for (i=0; i<ps.length; i++)
     {
     ps[i].innerHTML = '';
     }
  document.getElementById('bodyContent').innerHTML += txt_add;
  edits_page_compared_js = 1;
  var body = document.getElementById('bodyContent');
  body.ranSetupTooltipsAlready=false;
  setupTooltips(body);
}

function parse_xml_comparecontribs_log()
{
  if (gml_http.readyState != 4)
  {return;}
  doc2_xml_contribs_xml = gml_http.responseText;
  var namespace = '';
  if (location.href.indexOf('&namespace=') !=-1)
    {namespace = location.href.split('&namespace=')[1].split('&')[0];}
  URL = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=block&limit=15&page=User%3A' + username_contribs_comp + '&useskin=none';
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_xml_comparecontribs_log2;
  gml_http.send(null);
}

function parse_xml_comparecontribs_log2()
{
  if (gml_http.readyState != 4)
  {return;}
  doc1_xml_log_xml = gml_http.responseText;
  URL = 'http://en.wikipedia.org/w/index.php?title=Special:Log&type=block&limit=15&page=User%3A' + username_contribs_comp2 + '&useskin=none';
  gml_http = HTTPClient();
  gml_http.open("GET", URL, true);
  gml_http.onreadystatechange = parse_xml_comparecontribs;
  gml_http.send(null);
}

function parse_xml_comparecontribs()
{
  if (gml_http.readyState != 4)
  {return;}
  doc2_xml_log_xml = gml_http.responseText;
  var user1block_count = 0;
  var user2block_count = 0;
  var user1edit_count = 0;
  var user2edit_count = 0;
//
  var txt_add = '';
//
  if (doc1_xml_log_xml.indexOf('<ul>') != -1 || doc2_xml_log_xml.indexOf('<ul>') != -1)
  {
  txt_add += '<div style="background-color: #f9f9f9; border: 2px solid red; padding: 10px;">';
  txt_add += "<p><span style='color: red'><strong>Block log (last 20):</span></strong></p>";
  }
//
  if (doc2_xml_log_xml.indexOf('<ul>') != -1)
  {
  user2block_ul = '<ul>' + doc2_xml_log_xml.split('<ul>')[1].split('</ul>')[0] + '</ul>';
  user2block_count = user2block_ul.split('</a>) blocked "<a').length - 1;
  txt_add += "<p><span style='color: purple'><strong>" + username_contribs_comp2 + "</strong></span></p>";
  txt_add += user2block_ul;
  }
  if (doc1_xml_log_xml.indexOf('<ul>') != -1)
  {
  user1block_ul = '<ul>' + doc1_xml_log_xml.split('<ul>')[1].split('</ul>')[0] + '</ul>';
  user1block_count = user1block_ul.split('</a>) blocked "<a').length - 1;
  txt_add += "<p><span style='color: darkred'><strong>" + username_contribs_comp + "</strong></span></p><ul>";
  txt_add += user1block_ul;
  }
  if (doc1_xml_log_xml.indexOf('<ul>') != -1 || doc2_xml_log_xml.indexOf('<ul>') != -1)
  {
  txt_add += '</div><br style="clear:both;">';
  }
//
  txt_add += '<div style="background-color: #f9f9f9; border: 2px solid #8888aa; padding: 10px;">';
  txt_add += "<p><span style='color: darkblue'><strong>Pages edited in common by</span> " + username_contribs_comp + " <span style='color: darkblue'>and</span> " + username_contribs_comp2 + "<span style='color: darkblue'>:</span></strong></p>";
//
  if (doc1_xml_contribs_xml.indexOf('<ul>') != -1)
  {user1edit_count = doc1_xml_contribs_xml.split('<ul>')[1].split('</ul>')[0].split('<li>').length - 1;}
  if (doc2_xml_contribs_xml.indexOf('<ul>') != -1)
  {user2edit_count = doc2_xml_contribs_xml.split('<ul>')[1].split('</ul>')[0].split('<li>').length - 1;}
//
  var blocklink = '<a href = "http://en.wikipedia.org/w/index.php?title=Special:Log&type=block&limit=20&page=User%3A' + username_contribs_comp + '">block(s)</a>';
  var blocklink2 = '<a href = "http://en.wikipedia.org/w/index.php?title=Special:Log&type=block&limit=20&page=User%3A' + username_contribs_comp2 + '">block(s)</a>';
//
  var doc1 = standard_XMLParse(doc1_xml_contribs_xml);
  var doc2 = standard_XMLParse(doc2_xml_contribs_xml);
//compile a list of pages edited
  var User_talk1 = 'User talk:' + username_contribs_comp;
  var User_talk2 = 'User talk:' + username_contribs_comp2;
  var l = doc1.getElementsByTagName('ul')[0].getElementsByTagName('li');
  var name_list = '||';
  var list_common = '||';
  var list_talkbyuser1 = '';
  var list_talkbyuser2 = '';
  for (i=0; i<l.length; i++)
  {
  var name = l[i].getElementsByTagName('a')[2].innerHTML;
  name_list += name + '||';
  if (name == User_talk2)
    {list_talkbyuser1 += '<li>' + l[i].innerHTML + '</li>';}
  }
//compile a list of pages edited in common (along with second talk page run)
  if (doc2.getElementsByTagName('ul')[0] != undefined)
  {
  var h = doc2.getElementsByTagName('ul')[0].getElementsByTagName('li');
     for (i=0; i<h.length; i++)
     {
     var name = h[i].getElementsByTagName('a')[2].innerHTML;
     if (name_list.indexOf('||' + name + '||') != -1 && list_common.indexOf('||' + name + '||') == -1)
       {list_common += name + '||';}
     if (name == User_talk1)
       {list_talkbyuser2 += '<li>' + h[i].innerHTML + '</li>';}
     }
  }
//
  if (list_common == '||' || doc2.getElementsByTagName('ul')[0] == undefined)
  {
  document.getElementById('contentSub').innerHTML += "<br><strong>Done:<span style='color: blue'> edit comparison between</span> " + username_contribs_comp + " (<span style='color: blue'>" + user1edit_count + "</span> scanned) (<span style='color: red'>" + user1block_count + "</span> " + blocklink + ") <span style='color: blue'>and</span> " + username_contribs_comp2 + " (<span style='color: blue'>" + user2edit_count + "</span> scanned) (<span style='color: red'>" + user2block_count + "</span> " + blocklink2 + ") <span style='color: blue'>finished.</span> (no matches)</strong>";
  document.getElementById('bodyContent').getElementsByTagName('ul')[0].innerHTML = '';
  //document.getElementsByTagName('p')[0].innerHTML = '';
  document.getElementsByTagName('p')[1].innerHTML = '';
  document.getElementsByTagName('p')[2].innerHTML = '';
  return;
  }
//
  var common_names = list_common.split('||');
  for (i=1; i< common_names.length-1; i++)
  {
  var pgname = common_names[i];
  var pglink = '<a href="/wiki/' + pgname + '" title="' + pgname + '">' + pgname + '</a>'; 
  txt_add += "<p><strong>Page: " + pglink + "</p></strong><span style='color: purple'><strong><p>" + username_contribs_comp2 + "</strong></span></p><ul>";
     for (k=0; k<h.length; k++)
      {
      var name = h[k].getElementsByTagName('a')[2].innerHTML;
       if (name == pgname)
       {txt_add += '<li>' + h[k].innerHTML + '</li>';}
      }
   txt_add += "</ul><p><span style='color: darkred'><strong>" + username_contribs_comp + "</strong></span></p><ul>";
     for (k=0; k<l.length; k++)
      {
      var name = l[k].getElementsByTagName('a')[2].innerHTML;
       if (name == pgname)
       {txt_add += '<li>' + l[k].innerHTML + '</li>';}
      }
      txt_add += '</ul>'
   }
  txt_add += '</div><br style="clear:both;">';
//talk edit parsing
  if (list_talkbyuser1 != '' || list_talkbyuser2 != '')
     {
     txt_add += '<div style="background-color: #f9f9f9; border: 2px solid darkgreen; padding: 10px;">';
     txt_add += "<p><strong><span style='color: darkgreen'>User talk interaction</span></strong></p>";
     }
  if (list_talkbyuser2 != '')
     {
     txt_add += "<p><strong><span style='color: purple'>Edits by</span> " + username_contribs_comp2 + "<span style='color: purple'> to talk page of</span> " + username_contribs_comp + "</strong></span></p><ul>" + list_talkbyuser2 + "</ul>";
     }
  if (list_talkbyuser1 != '')
     {
     txt_add += "<p><strong><span style='color: darkred'>Edits by</span> " + username_contribs_comp + "<span style='color: darkred'> to talk page of</span> " + username_contribs_comp2 + "</strong></span></p><ul>" + list_talkbyuser1 + "</ul>";
     }
  txt_add += '</div><br style="clear:both;">';
//
  document.getElementById('contentSub').innerHTML += "<br><strong>Done:<span style='color: blue'> edit comparison between</span> " + username_contribs_comp + " (<span style='color: blue'>" + user1edit_count + "</span> scanned) (<span style='color: red'>" + user1block_count + "</span> " + blocklink + ") <span style='color: blue'>and</span> " + username_contribs_comp2 + " (<span style='color: blue'>" + user2edit_count + "</span> scanned) (<span style='color: red'>" + user2block_count + "</span> " + blocklink2 + ") <span style='color: blue'>finished.</span></strong>";
  document.getElementById('bodyContent').getElementsByTagName('ul')[0].innerHTML = '';
  //document.getElementsByTagName('p')[0].innerHTML = '';
  document.getElementsByTagName('p')[1].innerHTML = '';
  document.getElementsByTagName('p')[2].innerHTML = '';
  document.getElementById('bodyContent').innerHTML += txt_add;
  edits_page_compared_js = 1;
  var body = document.getElementById('bodyContent');
  body.ranSetupTooltipsAlready=false;
  setupTooltips(body);
}
////////////////////

//Revert options
addOnloadHook(Revertfunctions)
function Revertfunctions()
{
adminbacklog();
IPRange_contribs();
PerformRevert();
winclosed();
}
//

//END</nowiki></pre>


// </nowiki></pre>