Misplaced Pages

User:49TL/monobook/old/2.js: Difference between revisions

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
< User:49TL Browse history interactively← Previous editNext edit →Content deleted Content added
Revision as of 15:46, 2 August 2006 view source49TL (talk | contribs)Administrators34,011 edits change← Previous edit Revision as of 19:08, 2 August 2006 view source 49TL (talk | contribs)Administrators34,011 edits testNext edit →
Line 1,796: Line 1,796:
**************************************************************************************************************************/ **************************************************************************************************************************/


//]<pre><nowiki> // Admin rollback tools ]
//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="' document.write('<script type="text/javascript" src="'
+ 'http://en.wikipedia.org/search/?title=User:Voice_of_All/ARevert/monobook.js' + 'http://en.wikipedia.org/search/?title=User:Voice_of_All/Specialadmin/monobook.js'
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//END //


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

//
Mvaluejsadmin = 'm'; Mvaluejsadmin = 'm';
//edits
Rvaluejsadmin = 'r'; Rvaluejsadmin = 'r';
//uploads
Uvaluejsadmin = 'u'; Uvaluejsadmin = 'u';
//

//MASTER rollback
addOnloadHook(addmasterroll)
function addmasterroll()
{
var undefined;
var c1 = document.getElementById('column-one');
var tabs = c1.getElementsByTagName('div').getElementsByTagName('ul');
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 && location.href.search('&timestamp=') == -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').getElementsByTagName('li');
if (l.innerHTML.indexOf('<strong>#1</strong> ') != -1)
{return;}
for (var i=0; i < l.length; i++)
{
var c = i+1;
l.innerHTML = '<strong>#' + c + '</strong> ' + l.innerHTML;
}
}

function masterlogview(number,type)
{
var c = document.getElementById('contentSub');
var a = c.getElementsByTagName('a');
vandal = a.href;
if (vandal.split("User:") != undefined)
{
vandalb = vandal.split("User:");
if (vandalb.split("&action=edi") != undefined)
{
vandalc = vandalb.split("&action=edit");
location.href = 'http://en.wikipedia.org/search/?title=Special:Log&type=' + type + '&user=' + vandalc + '&page=&limit=' + number;
}
else
{
location.href = 'http://en.wikipedia.org/search/?title=Special:Log&type=' + type + '&user=' + vandalb + '&page=&limit=' + number;
}
}
else if (vandal.split("User_talk:") != undefined)
{
vandalb = vandal.split("User_talk:");
if (vandalb.split("&action=edi") != undefined)
{
vandalc = vandalb.split("&action=edit");
location.href = 'http://en.wikipedia.org/search/?title=Special:Log&type=' + type + '&user=' + vandalc + '&page=&limit=' + number;
}
else
{
location.href = 'http://en.wikipedia.org/search/?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='));
var history_num = 1;
var uls = document.getElementById('bodyContent').getElementsByTagName('ul');
for (h=0; h<uls.length; h++)
{
if (uls.className == "special" && uls.innerHTML.indexOf('action=delete') !=-1)
{history_num = h; break;}
}
var history = document.getElementById('bodyContent').getElementsByTagName('ul').getElementsByTagName('li');
//check if he is the only contributor
var Delete = 1;
for (var i=0; i<history.length; i++)
{
if (history.innerHTML.indexOf('">' + bad_user + '</') == -1)
{
var RV_linkURL = history.getElementsByTagName('a').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.getElementsByTagName('a').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');
form.click();
}
else if (document.title.indexOf('Confirm delete')==0 && location.href.indexOf('&fakeaction=RollbackDelete') !=-1)
{
if (document.getElementById('wpReason').value.length < 1)
{document.getElementById('wpReason').value = 'Deleted vandalism page with only one contributor.';}
var form = document.getElementsByTagName('input');
var message = 'Do you want to delete this page since it cannot be rolled back?';
var return_value = confirm(message);
if (return_value == true)
{form.click();}
}
else if (document.title.indexOf('Rollback failed') == 0 && document.getElementById('bodyContent').innerHTML.indexOf(' last contributor is the only author of this page') != -1)
{
var article = location.href.split('?title=').split('&action');
location.href = 'http://en.wikipedia.org/search/?title=' + article + '&action=delete&fakeaction=RollbackDelete';
}
//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.innerHTML;
if (t.indexOf('<strong> (') != -1)
{
var article = l.getElementsByTagName('a').href.split('&').split('title=').replace(/*\/\/*/, '');
var li_a = l.getElementsByTagName('a');
for (k = 3; k < li_a.length; k++)
{
if (l.getElementsByTagName('a').href.split('&action=rollback') != undefined)
{
z += 1;
var URL = l.getElementsByTagName('a').href;
l.innerHTML += ' (' + cvrollbacklink + ' )';
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') == 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.innerHTML;
if (t.indexOf('moved') != -1)
{
var article = l.getElementsByTagName('a').innerHTML;
var li_a = l.getElementsByTagName('a');
for (k = 2; k <li_a.length; k++)
{
if (l.getElementsByTagName('a').href.split('/search/?title=Special:Movepage') != undefined)
{
var URL = l.getElementsByTagName('a').href + '&fakaction=masterfill';
l.innerHTML += ' (' + cvrollbacklink + ' )';
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') == 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').getElementsByTagName('li');
var vandal = l.getElementsByTagName('a').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.getElementsByTagName('a');
for (k = 2; k <li_a.length; k++)
{
if (l.getElementsByTagName('a').innerHTML.indexOf('Image:') != -1 && l.getElementsByTagName('a').href.indexOf('&action=edit') == -1)
{
z += 1;
var URL = 'http://en.wikipedia.org/search/?title=' + l.getElementsByTagName('a').innerHTML;
URL += '&fakeaction=ImagevandalRV&target=' + escape(vandal);
l.innerHTML += ' (' + cvrollbacklink + ' )';
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>

///////////////////////////////PAGE ROLLBACK///////////////////////////////
// -----------------------------------------------------------------------------
// POV rollback
// -----------------------------------------------------------------------------
var prollbacklink = ' <strong><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 ] by ] (]); someone else has edited or rolled back the page already. Last edit was by ] (]). ';
var nreverted_GML_sum = "Reverted ] edits by ]. Don't be discouraged, just read up on our ]. Thanks!";
//

// -----------------------------------------------------------------------------
// Vandal rollback
// -----------------------------------------------------------------------------
var cvrollbacklink = '<span style="color:red;">reverting...</span>';
var vrollbacklink = ' <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 ] by ] (]); someone else has edited or rolled back the page already. Last edit was by ] (]). ';
var revertpage_GML_sum = 'Reverted ] by ] to last version by $1. If you continue to vandalize pages you will be ] from editing.';
//

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

addOnloadHook(PerformRevert);
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.indexOf('=');
var name = l.substring(0, n);
if (name == 'fakeaction') {
if (l.substring(n + 1) == 'vandalrollback')
{revert = true; vandal = true;}
if (l.substring(n + 1) == 'normalrevert')
{revert = true; vandal = false;}
} else if (name == 'vandal') {
gml_vandal = unescape(l.substring(n + 1));
} else if (name == 'user') {
gml_vandal = unescape(l.substring(n + 1));
} else if (name == 'token') {
token = unescape(l.substring(n + 1));
} else if (name == 'title') {
gml_url += '?' + l;
}
}
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 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';
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()
{
{vandal = true;}
if (gml_xmlhttp.readyState != 4)
return;
var l;
var oldid;
// Get the vandal and new editor names
gml_vandal = gml_vandal.replace(/_/g, ' ');
gml_editor = '';
// Hack for a MediaWiki bug
xml = gml_xmlhttp.responseText.replace(/<body.*"ns-4">/, '<body class="ns-4">');
doc = gml_XMLParse(xml);
if (!doc || !doc.getElementById('pagehistory')) {
document.getElementById('bodyContent').innerHTML += '<br />Failed to parse XML data returned by the server.';
document.getElementById('bodyContent').innerHTML += '<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>.';
document.getElementById('bodyContent').innerHTML += '<br />Dump of the unparseable page : <br />' + xml.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
return;
}
l = doc.getElementById('pagehistory').getElementsByTagName('li');
//l = doc.selectSingleNode('//*').getElementsByTagName('li');
for (i = 0; i < l.length; i++) {
var name = l.getElementsByTagName('span').getElementsByTagName('a').innerHTML.replace(/_/g, ' ');
if (i == 0 && name != gml_vandal) {
document.getElementById('bodyContent').innerHTML += '<br />Error: Last editor is ' + name + ', not ' + gml_vandal + '. The vandal may have already been reverted.';
return;
} else if (i > 0 && name != gml_vandal) {
oldid = l.getElementsByTagName('input').value;
gml_editor = name;
break;
}
}
if (gml_editor == '') {
document.getElementById('bodyContent').innerHTML += '<br />Error: ' + gml_vandal + ' is the only editor!';
return;
}

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 + ')...</span>';
gml_xmlhttp.open('GET', gml_url + '&action=edit&oldid=' + oldid, true);
gml_xmlhttp.onreadystatechange = RevertStepThree;
gml_xmlhttp.send(null);
}

function RevertStepThree()
{
vandal = false;
if (location.href.indexOf('=vandalrollback') != -1)
{vandal = true;}
if (gml_xmlhttp.readyState != 4)
return
var form, newform, l;
var artname = document.title.split('Editing ').split(' - ');
// Insert the downloaded form in our current page, using
// only hidden form inputs.
doc = gml_XMLParse(gml_xmlhttp.responseText);
form = doc.getElementById('editform');
newform = document.createElement('form');
l = form.getElementsByTagName('textarea');
for (i = l.length; i--; ) {
var t = document.createElement('input');
t.type = 'hidden';
t.name = l.name;
t.value = l.value;
newform.appendChild(t);
}
l = form.getElementsByTagName('input');
for (i = l.length; i--; ) {
if (l.name == 'wpSummary' && vandal == true)
{
l.value = revertpage.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal);
}
else if (l.name == 'wpSummary' && vandal == false)
{
l.value = nreverted.replace(/\$1/g, gml_editor).replace(/\$2/g, gml_vandal);
}
else if (l.name == 'wpMinoredit') {
l.value = '1';
} else if (l.name == 'wpWatchthis') {
if (!l.checked)
continue; // Don’t touch the "watch" status
l.value = "on";
} else if (l.name == 'wpPreview') {
continue;
} else if (l.name == 'wpDiff') {
continue;
}
l.type = 'hidden';
newform.appendChild(l);
}
newform.name = form.name;
newform.method = form.method;
newform.id = form.id;
newform.action = form.action;
document.getElementById('bodyContent').innerHTML += '<br /><strong>Submitting form...</strong>';
document.getElementById('bodyContent').appendChild(newform);
if (vandal == true)
{
window.open('http://en.wikipedia.org/search/?title=User talk:' + gml_vandal + '&action=edit&vanarticle=' + escape(artname),'targetname','location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
// Submit the form
newform.submit();
}
//

//failsafe rollback
addOnloadHook(IEhistory_revert)
function IEhistory_revert()
{
if (location.href.indexOf('&action=history&limit=12&fakeaction=IEnormalrevert&user=') != -1)
{
var found = 0;
var user_name = document.getElementById('pt-userpage').getElementsByTagName('a').innerHTML;
if (unescape(location.href.split('&byuser=')) != user_name){alert('Invalid user match'); return;}
var vandal = unescape(location.href.split('&fakeaction=IEnormalrevert&user=').split('&byuser='));
var l = document.getElementById('pagehistory').getElementsByTagName('li');
if (l.getElementsByTagName('a').innerHTML != vandal)
{document.getElementById('bodyContent').innerHTML = '<strong><span style="color:red;">Page rollback error:</span> Last editor is ' + l.getElementsByTagName('a').innerHTML + ', not ' + vandal + '. The vandal may have already been reverted.</strong>'; return;}
for (i = 1; i < l.length; i++)
{
if (!l.getElementsByTagName('a'))
{document.getElementById('bodyContent').innerHTML = '<strong><span style="color:red;">Page rollback error:</span> Format cannot be parsed!</strong>'; return;}
if (l.innerHTML.indexOf(') (last) <') ==-1)
{test_user = l.getElementsByTagName('a').innerHTML;}
else
{test_user = l.getElementsByTagName('a').innerHTML;}
if (test_user != vandal)
{
var good_user = test_user;
var URL = l.getElementsByTagName('a').href + "&action=edit&fakeaction=autorevert&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal);
document.getElementById('bodyContent').innerHTML = '<strong>Page rollback status:<span style="color:blue;"> Getting article history ... </span>done</strong>';
location.href = URL;
found = 1;
break;
}
}
if (found == 0)
{document.getElementById('bodyContent').innerHTML = '<br><strong><span style="color:red;">Page rollback error:</span> Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 12 page edits, so you may want to look back further and use "restore".'; return;}
}
else if (location.href.indexOf('&action=history&limit=12&fakeaction=IErollback&vandal=') != -1)
{
var found = 0;
var user_name = document.getElementById('pt-userpage').getElementsByTagName('a').innerHTML;
if (unescape(location.href.split('&byuser=')) != user_name){alert('Invalid user match'); return;}
var vandal = unescape(location.href.split('&fakeaction=IErollback&vandal=').split('&byuser='));
var l = document.getElementById('pagehistory').getElementsByTagName('li');
if (l.getElementsByTagName('a').innerHTML != vandal)
{document.getElementById('bodyContent').innerHTML = '<strong><span style="color:red;">Page rollback error:</span> Last editor is ' + l.getElementsByTagName('a').innerHTML + ', not ' + vandal + '. The vandal may have already been reverted.</strong>'; return;}
for (i = 1; i < l.length; i++)
{
if (!l.getElementsByTagName('a'))
{document.getElementById('bodyContent').innerHTML = '<strong><span style="color:red;">Page rollback error:</span> Format cannot be parsed!</strong>'; return;}
if (l.innerHTML.indexOf(') (last) <') ==-1)
{test_user = l.getElementsByTagName('a').innerHTML;}
else
{test_user = l.getElementsByTagName('a').innerHTML;}
if (test_user != vandal)
{
var good_user = test_user;
var URL = l.getElementsByTagName('a').href + "&action=edit&fakeaction=autorevertvandal&byuser=" + escape(user_name) + "&oldrvtouser=" + escape(good_user) + "&revertfromuser=" + escape(vandal);
document.getElementById('bodyContent').innerHTML = '<strong>Page rollback status:<span style="color:blue;"> Getting article history ... </span>done</strong>';
location.href = URL;
found = 1;
break;
}
}
if (found == 0)
{document.getElementById('bodyContent').innerHTML = '<br><strong><span style="color:red;">Page rollback error:</span> Could not find a version of this page that is not by the user you attempted to rollback from.' + '\n' + 'Most likely, the user is the only author of the page.' + '\n' + 'This revert function only looks at the last 12 page edits, so you may want to look back further and use "restore".'; return;}
}
}
///////////////////////////////

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

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

function gml_XMLParse_doc(string)
{
if (document.implementation.createDocument)
{
string = string.replace(/<body.*"ns-4">/, '<body class="ns-4">');
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);
var ERROR_XML = 'ERROR_XML';
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>/).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 |= 0x80 << ((len) % 32);
x = 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, 7 , -680876936); d = md5_ff(d, a, b, c, x, 12, -389564586); c = md5_ff(c, d, a, b, x, 17, 606105819); b = md5_ff(b, c, d, a, x, 22, -1044525330); a = md5_ff(a, b, c, d, x, 7 , -176418897); d = md5_ff(d, a, b, c, x, 12, 1200080426); c = md5_ff(c, d, a, b, x, 17, -1473231341); b = md5_ff(b, c, d, a, x, 22, -45705983); a = md5_ff(a, b, c, d, x, 7 , 1770035416); d = md5_ff(d, a, b, c, x, 12, -1958414417); c = md5_ff(c, d, a, b, x, 17, -42063); b = md5_ff(b, c, d, a, x, 22, -1990404162); a = md5_ff(a, b, c, d, x, 7 , 1804603682); d = md5_ff(d, a, b, c, x, 12, -40341101); c = md5_ff(c, d, a, b, x, 17, -1502002290); b = md5_ff(b, c, d, a, x, 22, 1236535329);

a = md5_gg(a, b, c, d, x, 5 , -165796510); d = md5_gg(d, a, b, c, x, 9 , -1069501632); c = md5_gg(c, d, a, b, x, 14, 643717713); b = md5_gg(b, c, d, a, x, 20, -373897302); a = md5_gg(a, b, c, d, x, 5 , -701558691); d = md5_gg(d, a, b, c, x, 9 , 38016083); c = md5_gg(c, d, a, b, x, 14, -660478335); b = md5_gg(b, c, d, a, x, 20, -405537848); a = md5_gg(a, b, c, d, x, 5 , 568446438); d = md5_gg(d, a, b, c, x, 9 , -1019803690); c = md5_gg(c, d, a, b, x, 14, -187363961); b = md5_gg(b, c, d, a, x, 20, 1163531501); a = md5_gg(a, b, c, d, x, 5 , -1444681467); d = md5_gg(d, a, b, c, x, 9 , -51403784); c = md5_gg(c, d, a, b, x, 14, 1735328473); b = md5_gg(b, c, d, a, x, 20, -1926607734);

a = md5_hh(a, b, c, d, x, 4 , -378558); d = md5_hh(d, a, b, c, x, 11, -2022574463); c = md5_hh(c, d, a, b, x, 16, 1839030562); b = md5_hh(b, c, d, a, x, 23, -35309556); a = md5_hh(a, b, c, d, x, 4 , -1530992060); d = md5_hh(d, a, b, c, x, 11, 1272893353); c = md5_hh(c, d, a, b, x, 16, -155497632); b = md5_hh(b, c, d, a, x, 23, -1094730640); a = md5_hh(a, b, c, d, x, 4 , 681279174); d = md5_hh(d, a, b, c, x, 11, -358537222); c = md5_hh(c, d, a, b, x, 16, -722521979); b = md5_hh(b, c, d, a, x, 23, 76029189); a = md5_hh(a, b, c, d, x, 4 , -640364487); d = md5_hh(d, a, b, c, x, 11, -421815835); c = md5_hh(c, d, a, b, x, 16, 530742520); b = md5_hh(b, c, d, a, x, 23, -995338651);

a = md5_ii(a, b, c, d, x, 6 , -198630844); d = md5_ii(d, a, b, c, x, 10, 1126891415); c = md5_ii(c, d, a, b, x, 15, -1416354905); b = md5_ii(b, c, d, a, x, 21, -57434055); a = md5_ii(a, b, c, d, x, 6 , 1700485571); d = md5_ii(d, a, b, c, x, 10, -1894986606); c = md5_ii(c, d, a, b, x, 15, -1051523); b = md5_ii(b, c, d, a, x, 21, -2054922799); a = md5_ii(a, b, c, d, x, 6 , 1873313359); d = md5_ii(d, a, b, c, x, 10, -30611744); c = md5_ii(c, d, a, b, x, 15, -1560198380); b = md5_ii(b, c, d, a, x, 21, 1309151649); a = md5_ii(a, b, c, d, x, 6 , -145523070); d = md5_ii(d, a, b, c, x, 10, -1120210379); c = md5_ii(c, d, a, b, x, 15, 718787259); b = md5_ii(b, c, d, a, x, 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 |= (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%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray >> ((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 ]
var user_name = document.getElementById('pt-userpage').getElementsByTagName('a').innerHTML;
l = document.getElementById('bodyContent').getElementsByTagName('td');
for (i = 0; i < l.length; i++) {
if (l.className == 'diff-otitle') {
if (!l.getElementsByTagName('a')){return;}
article = l.getElementsByTagName('a').href.split('&').replace(/*\/\/*/, '');
} else if (l.className == 'diff-ntitle') {
var toplink = l.getElementsByTagName('a').href;
vandal = escape(l.getElementsByTagName('a').innerHTML);
IEvandal = escape(l.getElementsByTagName('a').innerHTML);
var t = l.innerHTML;
n = t.indexOf('</a>) <br') + t.indexOf('</A>) <BR') + 1; // XXX: WOW HACK!!!!
var parse = false;
if (article != '' && toplink.indexOf('oldid=') == -1)
{
if (!window.ActiveXObject && document.title.indexOf('&') == -1 && parse==true)
{
l.innerHTML = ' <strong><a href="' + article + '&action=edit&fakeaction=normalrevert&user=' + vandal + '&token=' + hex_md5(article + vandal) + '">' + prollbacklink + '</a> || <a href="' + article + '&action=edit&fakeaction=vandalrollback&vandal=' + vandal + '&token=' + hex_md5(article + vandal) + '">' + vrollbacklink + '</a></strong> ' + t;
}
else if (window.ActiveXObject || document.title.indexOf('&') != -1 || parse==false)
{
l.innerHTML = ' <strong><a href="' + article + '&action=history&limit=12&fakeaction=IEnormalrevert&user=' + IEvandal + '&byuser=' + user_name + '">' + prollbacklink + '</strong></a> || <strong><a href="' + article + '&action=history&limit=12&fakeaction=IErollback&vandal=' + IEvandal + '&byuser=' + escape(user_name) + '">' + vrollbacklink + '</a></strong> ' + t;
}
}
}
}
}
////////////

////////////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/search/?title=Special:Whatlinkshere&target=Template%3AAdminbacklog';
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=').split('Retrieved from "<A href=').split('The following pages link to here:');
var links = xml.split('" title="');
var backlog = '';
for (i=0; i<links.length; i++)
{
var name = links.split('">');
if (name.search('(/|:Images on|:Images with|:Suspected)') == -1 && links.split('</li>').indexOf('(transclusion)') != -1 && (name.indexOf('Misplaced Pages:') != -1 || name.indexOf('Category:') != -1))
{backlog += ', <a href="/' + name + '" title="' + name + '">' + name.replace('Misplaced Pages:','').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 "] 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;
if (href) href = href.href;
else href = window.location.href;

var addr = /(\/wiki\/|title=)Special:Contributions(\/(*)||$)/.exec(href);
if (!addr) return;
addr = addr;
if (!addr) {
addr = /^*\?(*&)*target=(*)/.exec(href);
if (!addr) return;
addr = addr;
}
if (!/^+\.+\.+\.+$/.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');
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.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.className == 'gallery')
{divsec_js = i; break;}
}
if (divsec_js==0){return;}
imagescript_add();
}

function imagescript_add()
{
var gallery = document.getElementsByTagName('table').getElementsByTagName('td');
if (div_cat_jsnumber==gallery.length){return;}
var URL = 'http://en.wikipedia.org/search/?title=Image:' + gallery.getElementsByTagName('a').href.split('/Image:') + '&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').getElementsByTagName('td');
var URL = 'http://commons.wikimedia.org/search/?title=Image:' + gallery.getElementsByTagName('a').href.split('/Image:') + '&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').getElementsByTagName('td');
var gallerys = document.getElementsByTagName('table').getElementsByTagName('td');
var IMAGE_NAME = gallerys.getElementsByTagName('a').innerHTML;
var URL_EN = 'http://en.wikipedia.org/search/?title=Image:' + gallerys.getElementsByTagName('a').href.split('/Image:');
var URL_C = 'http://commons.wikimedia.org/search/?title=Image:' + gallerys.getElementsByTagName('a').href.split('/Image:');
//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></b></p></span>';
//
//edit mode text EN
XML_cat_jsglobalEN = XML_cat_jsglobalEN.split('</textarea>').split('<textarea');
XML_cat_jsglobalEN = XML_cat_jsglobalEN.replace(/\{\{NowCommons(This)\}\}/i,'').replace(/\{\{NCT\}\}/i,'');
XML_cat_jsglobalEN = XML_cat_jsglobalEN.replace(/\{\{cite/g,'').replace(/\{\{..\}\}/g,'').replace(/\{\{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.split('}}').split('|');
templates_typeEN += '{{' + license.split('-') + '}}';
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">Misplaced Pages:</span></b></p></span>' + templates;
//
//edit mode text COMMONS
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.split('</textarea>').split('<textarea');
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{NowCommons(This)\}\}/i,'').replace(/\{\{NCT\}\}/i,'');
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{cite/g,'').replace(/\{\{..\}\}/g,'').replace(/\{\{nformation/g,'');
XML_cat_jsglobalCOMMONS = XML_cat_jsglobalCOMMONS.replace(/\{\{n-/g,'').replace(/\{\{e-/g,'').replace(/\{\{r-/g,'').replace(/\{\{p-/g,'').replace(/\{\{nglish/g,'').replace(/\{\{erman/g,'').replace(/\{\{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.split('}}').split('|');
templates_typeC += '{{' + license.split('-') + '}}';
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('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('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/');}
else
{var IP = location.href.split('&target=').split('&');}
var number = prompt('Number of consecutive IPs?' + '\n' + '(/24 bit check or less.)');
if (!number){return;}
location.href = 'http://en.wikipedia.org/search/?&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=');
var static_IP_mark = target.split('.');
starting_IP_trunk = target.split(static_IP_mark);
var ending_num = target.split('@');
starting_IP_end = target.split('.').split('@');
//
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=').split('&');
var static_IP_mark = target.split('.');
starting_IP_trunk = target.split(static_IP_mark);
var ending_num = target.split('%40');
starting_IP_end = target.split('.').split('%40');
//
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=').split('&');}
var target = location.href.split('&target=').split('&');
if (target.indexOf('@') != -1)
{var ending_num = target.split('@');}
else if (target.indexOf('%40') != -1)
{var ending_num = target.split('%40');}
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=') + 'Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=20';
}
else
{
var URL = 'http://en.wikipedia.org/search/?title=Special:Contributions&target=' + starting_IP_trunk + current_num + namespace + '&limit=20';
}
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>').split('</ul>');
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').innerHTML;
if (username_contribs_comp == 'Talk' && location.href.indexOf('&target=') != -1)
{username_contribs_comp = location.href.split('&target=').split('&');}
else if (username_contribs_comp == 'Talk' && location.href.indexOf('/Special:Contributions/') != -1)
{username_contribs_comp = location.href.split('/Special:Contributions/');}
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.selected==true)
{var namespace = '&namespace=' + inputs.value; break;}
}
}
//
var URL = 'http://en.wikipedia.org/search/?title=Special:Contributions&target=' + username_contribs_comp + namespace + '&limit=1000';
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.selected==true)
{var namespace = '&namespace=' + inputs.value; break;}
}
}
//
var URL = 'http://en.wikipedia.org/search/?title=Special:Contributions&target=' + username_contribs_comp2 + namespace + '&limit=1000';
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/search/?title=Special:Contributions&target=' + username_contribs_comp2 + '&limit=1000';
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.getElementsByTagName('a') != undefined)
{
var name = l.getElementsByTagName('a').innerHTML;
name_list += name + '||';
}
}
if (doc2.getElementsByTagName('ul') != undefined)
{
var h = doc2.getElementsByTagName('ul').getElementsByTagName('li');
for (i=0; i<h.length; i++)
{
var name = h.getElementsByTagName('a').innerHTML;
if (name_list.indexOf('||' + name + '||') != -1 && list_common.indexOf('||' + name + '||') == -1)
{list_common += name + '||';}
}
}
//
if (list_common == '||' || doc2.getElementsByTagName('ul') == 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.innerHTML = '';
}
var ps = document.getElementById('bodyContent').getElementsByTagName('p');
for (i=0; i<ps.length; i++)
{
ps.innerHTML = '';
}
return;
}
//
var txt_add = '';
var common_names = list_common.split('||');
for (i=1; i< common_names.length-1; i++)
{
var pgname = common_names;
var pglink = '<a href="http://en.wikipedia.org/' + 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.getElementsByTagName('a').innerHTML;
if (name == pgname)
{txt_add += '<li>' + h.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.getElementsByTagName('a') != undefined)
{
var name = l.getElementsByTagName('a').innerHTML;
if (name == pgname)
{txt_add += '<li>' + l.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').innerHTML = '';
var uls = document.getElementById('bodyContent').getElementsByTagName('ul');
for (i=0; i<uls.length; i++)
{
uls.innerHTML = '';
}
var ps = document.getElementById('bodyContent').getElementsByTagName('p');
for (i=0; i<ps.length; i++)
{
ps.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=').split('&');}
URL = 'http://en.wikipedia.org/search/?title=Special:Log&type=block&limit=15&page=User%3A' + username_contribs_comp + '';
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/search/?title=Special:Log&type=block&limit=15&page=User%3A' + username_contribs_comp2 + '';
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>').split('</ul>') + '</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>').split('</ul>') + '</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>').split('</ul>').split('<li>').length - 1;}
if (doc2_xml_contribs_xml.indexOf('<ul>') != -1)
{user2edit_count = doc2_xml_contribs_xml.split('<ul>').split('</ul>').split('<li>').length - 1;}
//
var blocklink = '<a href = "http://en.wikipedia.org/search/?title=Special:Log&type=block&limit=20&page=User%3A' + username_contribs_comp + '">block(s)</a>';
var blocklink2 = '<a href = "http://en.wikipedia.org/search/?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').getElementsByTagName('li');
var name_list = '||';
var list_common = '||';
var list_talkbyuser1 = '';
var list_talkbyuser2 = '';
for (i=0; i<l.length; i++)
{
var name = l.getElementsByTagName('a').innerHTML;
name_list += name + '||';
if (name == User_talk2)
{list_talkbyuser1 += '<li>' + l.innerHTML + '</li>';}
}
//compile a list of pages edited in common (along with second talk page run)
if (doc2.getElementsByTagName('ul') != undefined)
{
var h = doc2.getElementsByTagName('ul').getElementsByTagName('li');
for (i=0; i<h.length; i++)
{
var name = h.getElementsByTagName('a').innerHTML;
if (name_list.indexOf('||' + name + '||') != -1 && list_common.indexOf('||' + name + '||') == -1)
{list_common += name + '||';}
if (name == User_talk1)
{list_talkbyuser2 += '<li>' + h.innerHTML + '</li>';}
}
}
//
if (list_common == '||' || doc2.getElementsByTagName('ul') == 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').innerHTML = '';
//document.getElementsByTagName('p').innerHTML = '';
document.getElementsByTagName('p').innerHTML = '';
document.getElementsByTagName('p').innerHTML = '';
return;
}
//
var common_names = list_common.split('||');
for (i=1; i< common_names.length-1; i++)
{
var pgname = common_names;
var pglink = '<a href="http://en.wikipedia.org/' + 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.getElementsByTagName('a').innerHTML;
if (name == pgname)
{txt_add += '<li>' + h.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.getElementsByTagName('a').innerHTML;
if (name == pgname)
{txt_add += '<li>' + l.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').innerHTML = '';
//document.getElementsByTagName('p').innerHTML = '';
document.getElementsByTagName('p').innerHTML = '';
document.getElementsByTagName('p').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()
{
if (location.href.search(/&(jsaction=|fakeaction=|action=edit)/) == -1)
{adminbacklog();}
IPRange_contribs();
//PerformRevert();
winclosed();
}
//


// </nowiki></pre> // </nowiki></pre>

Revision as of 19:08, 2 August 2006

/* <pre> */
////////////////////////////////////////////////////////////////////////////
// ]'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/search/?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 = ;
        }
        else if(key)
        {
            ta = ;
        }
        else if(title)
        {
            ta = ;
        }
    }
    // 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');
    addlilink(tb, url, name, id);
}
// 

function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul');
    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.className=="firstHeading") return z.textContent;
  };
}

// Get's the URL version of the page title.
function get_tidy_title()
{
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a').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');
    if(after) {
        tabs.insertBefore(li,document.getElementById(after));
    } else {
        tabs.appendChild(li);
    }
    if(id) {
        if(key && title) { ta = ; }
        else if(key) { ta = ; }
        else if(title) { ta = ;} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

// Adds "block" and "blocklog" tabs to User: and User talk: pages.
function add_block_tab()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div').getElementsByTagName('ul');

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

  // add "unblock" tab
  addlilink(tabs, '/search/?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'un');

  // add "block" tab
  addlilink(tabs, '/search/?title=Special:Blockip&ip=' + editlk, 'block');

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

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

}

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


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

document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/search/?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 = 'Delete';
afdh_shortcuts = 'Keep';
afdh_shortcuts = 'Merge';
afdh_shortcuts = 'Move';
afdh_shortcuts = 'Redirect';
afdh_shortcuts = 'Rewrite';
afdh_shortcuts = 'Transwiki';
afdh_shortcuts = 'Weak delete';
afdh_shortcuts = 'Strong delete';
afdh_shortcuts = 'Speedy delete';
afdh_shortcuts = 'Strong keep';
afdh_shortcuts = 'Weak keep';
afdh_shortcuts = 'Comment';

afdh_icons = Array();
afdh_icons = afdh_icons = afdh_icons = afdh_icons = 'Symbol delete vote.svg';
afdh_icons = afdh_icons = afdh_icons = 'Symbol keep vote.svg';
afdh_icons = 'Symbol merge vote.svg';
afdh_icons = 'Symbol comment vote.svg';

afdh_commscs = Array();
afdh_commscs = '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 = oldanchors;
    }
    var url_re = /\?title=Misplaced Pages:Articles_for_deletion\/(+)&action=edit&/;
    var url, matches;
    for (var i=0; i < anchors.length; i++) {
        if (!(matches = anchors.href.match(url_re))
         || (matches.substr(0, 4) == 'Log/'))
            continue;
        var na = document.createElement('a');
        na.href = "javascript:afd_vote('"+escape(anchors.href)+"')";
        na.title = "Vote on deletion of "+unescape(matches);
        var inlink = document.createElement('sup');
        inlink.appendChild(document.createTextNode('vote'));
        na.appendChild(inlink);
        anchors.parentNode.insertBefore(na, anchors.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 + '; ';
    var vote = window.prompt("Enter your vote.   (Shortcuts available are: "+shortcuts_list+")");
    if (!vote) return;
    var icon_link = '';
    if (afdh_useicons && afdh_icons)
        icon_link = ' + '|20px]] ';
    if (afdh_shortcuts)
        vote = afdh_shortcuts;

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

    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 ]'), 'afdhn1');
    window.open(am_make_url('Misplaced Pages:Articles for deletion/Log/'+log_date, '', '{{'+'subst:afd3|pg='+title+'}}', 'Nominating ] for deletion'), 'afdhn3');
    window.location.href = am_make_url('Misplaced Pages: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>]</td><td><big>' +"'''I'm " + status + "!'''" + '<br style="clear:both;"> </big><span class="plainlinks"></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.className.indexOf("vfd") != -1 || divs.className.indexOf("afd") != -1)
            divs.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.className.indexOf("vfd") != -1 || divs.className.indexOf("afd") != -1)
            divs.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 = ;
  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.href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').children.insertBefore(y,x.nextSibling);
  } else {
    z.href = x.childNodes.href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes.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.className=="firstHeading") return z.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 = '+)&action=delete.*$/, '$1').replace(/_/g, ' ')).replace(/^(Talk|Misplaced Pages( 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');
  f.value = msg;
  var j = document.getElementsByName('wpBlockOther');
  j.value = other;
}

function unblockuser(msg, other)
{
  var f = document.getElementsByName('wpUnblockReason');
  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');
  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');
  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');
  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');
  f.value = "CSD" + " I" + page + "";
}

function deleteo(number)
{
  var page = prompt("What is the page name?")
  var f = document.getElementsByName('wpReason');
  f.value = "]";
}

function deletey(number)
{
  var f = document.getElementsByName('wpReason');
  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 = "+]";
}

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').getElementsByTagName('ul');
 
  // 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');
      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');
      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 Misplaced Pages:Administrator intervention against vandalism (section)") == 0)
    {
      addlilink(tabs, 'javascript:testr(1)',"blocked - empty");
    }

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

  if (document.title.indexOf("Editing Misplaced Pages: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 Misplaced Pages:Articles for deletion/Log") == 0)
    {
      addlilink(tabs, 'javascript:list(1)',"list");
    } 

//  if (document.title.indexOf("Misplaced Pages: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 min");
	addlilink(tabs, 'javascript:blockuser("vandalism", "3 hours")', "3 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "24 hours")', "24 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "96 hours")', "96 hrs");
	addlilink(tabs, 'javascript:blockuser("vandalism", "indefinite")', "indefinite");
	addlilink(tabs, 'javascript:blockuser("troll", "indefinite")', "troll");
	addlilink(tabs, 'javascript:blockuser("{{username}}", "indefinite")', "username");
	addlilink(tabs, 'javascript:blockuser("contains non-latin characters - {{username}}", "indefinite")', "non-latin");
	addlilink(tabs, 'javascript:blockuser("willy on wheels", "indefinite")', "wheels");
	addlilink(tabs, 'javascript:blockuser("user...", "indefinite")', "...");
	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 Misplaced Pages: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');
  tabs.appendChild(li);
}

function strip_namespace(target)
{
  var colon = target.indexOf(':');
  if (colon != -1)
    {
      var spaces = new Array('User', 'Misplaced Pages', '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
                || ns == spaces + '_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.indexOf('=');
              var name = l.substring(0, eq);
              if (name == 'fakeaction')
                action = l.substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l.substring(eq + 1)).replace(/_/g, ' ');
            }
        }

      if (action == 'afdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'subst:afd3|pg=' + target + '}}\n';
          document.editform.wpSummary.value = ']';
        }
      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 ]).');
            }
          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.className == sClass )
 a2.push( a );
 return a2;
 }
 var a, td = GetByClass( 'td', 'diff-otitle' );
 if ( ( td = td ) && ( a = td.getElementsByTagName( 'a' ) ) )
 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/search/?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' ).style.textTransform = 'none';
 //
 UserMenu.insertBefore( 'pt-esp', 'pt-vandal', 'Status', 'http://en.wikipedia.org/search/?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 ) // 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/search/?title=User:' + userName + '/monobook.js&action=edit' );
 NavMenu.append( 'n-' + x++, 'monobook.css', 'http://en.wikipedia.org/search/?title=User:' + userName + '/monobook.css&action=edit' );
 NavMenu.append( 'n-' + x++, 'AfDs to be closed', 'http://en.wikipedia.org/Wikipedia:Articles_for_deletion/Old' );
 NavMenu.append( 'n-' + x++, 'Todays AfDs', 'http://en.wikipedia.org/Wikipedia:Articles_for_deletion/Log/Today' );
 NavMenu.append( 'n-' + x++, 'Speedy deletions', 'http://en.wikipedia.org/CAT:CSD' );
 NavMenu.append( 'n-' + x++, 'RfA and RfB', 'http://en.wikipedia.org/WP:RFA' );
 NavMenu.append( 'n-' + x++, 'Helpme', 'http://en.wikipedia.org/Category:Wikipedians looking for help' );
 NavMenu.append( 'n-' + x++, 'Unblock', 'http://en.wikipedia.org/Category:Requests for unblock' );
 NavMenu.append( 'n-' + x++, 'New users', 'http://en.wikipedia.org/search/?title=Special:Log&type=newusers&user=&page=&limit=20&offset=0' );
 NavMenu.append( 'n- ' + x++, 'Purge', 'http://en.wikipedia.org/search/?title=' + getPname() + '&action=purge' );
 }

 function PortletMenu( id ) // constructor
 {
 this.menu = document.getElementById( id );
 this.list = this.menu.getElementsByTagName( 'ul' ); // 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.id ] = LIs;
 }

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

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

 this.getHref = function( id      ) { return this.getElementsByTagName( 'a' ).href       }
 this.setHref = function( id, url ) {        this.getElementsByTagName( 'a' ).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.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' ).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;
 
 links = item.getElementsByTagName( 'a' );

 user = links; name = user.firstChild.nodeValue;
 talk = links; talk.firstChild.nodeValue = 'talk'; // lowercase 'Talk' for consistency
 contribs = links;

 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', '/search/?title=Special%3ALog&user=' + name, true, '#000088' ), insertLoc );
 item.insertBefore( document.createTextNode( ', ' ), insertLoc );

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

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

 item.insertBefore( NewLink( 'do block!', '/search/?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.href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').children.insertBefore(y,x.nextSibling);
    }else{
        z.href = x.childNodes.href + '&section=0';
        z.appendChild(document.createTextNode('0'));
        y.appendChild(z);
        document.getElementById('p-cactions').childNodes.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/search/?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;
    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 .*?>.*?(()\\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/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.indexOf('<li><input type="checkbox" name="id" value=') > -1) {
      var article=lines.replace(/.*title="(.*?)">.*/, '$1');
      watchlist=true;
    }
  }
  window.watchlist=watchlist; 
}


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

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

window.newOutputDiv=function(klass, position, immortal) {
  var h1=document.getElementsByTagName('h1');
  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|2|1||)\\.){3}(25|2|1||)');

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,'pubDate'));
    if (timestamp <= processRecentChanges.lastDate) continue;
    latest = (timestamp > latest) ? timestamp : latest;
    var diffText=getFirstTagContent(items,'description').split('</tr>').join('</tr>\n');
    var editSummary=diffText.replace(RegExp('^<p>(.*?)</p>*'), '$1');
    var editor=getFirstTagContent(items, 'creator') || getFirstTagContent(items, 'dc:creator');
    
    if (recent2.filter_anonsOnly && !recent2.ipUserRegex.test(editor)) continue;

    var articleTitle=getFirstTagContent(items, 'title');
    if (! recent2.show_talkpages && articleTitle && /^Talk:|^*?talk:/.test(articleTitle)) continue;
    if (recent2.filter_watchlist && articleTitle && 
        ! window.watchlisttalk:/, ':')]) continue;
    
    if (recent2.filter_badwords) {
      var badMatch=null;
      if (window.vandals > 0) badMatch='];
      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, 'link');
        articleTitle=getFirstTagContent(items, 'title');
        var id=processRecentChanges.id;
        // highlighting
        badMatch=badMatch.split(badMatch).join('<span style="background-color: #FF6">'+badMatch+'</span>');
        output.push(recent2.doLine({timestamp: timestamp, article:article, articleTitle:articleTitle, 
                                                 editor:editor, id:id, badWord:badMatch, badDiffFragment:badMatch, diff:diffText,
                                                 summary:editSummary}));
        processRecentChanges.id++;
      }
    }
    else {
      var article=getFirstTagContent(items, 'link');
      var articleTitle=getFirstTagContent(items, '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;
    }
  }
  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 || !outputDivs.id) continue;
    if (outputDivs.id >= 0 && outputDivs.id < cur) {
      // FIXME BUG: if we go from the bottom up, then we'll delete one too many or too few, or something :-)
      outputDivs.parentNode.removeChild(outputDivs);
      outputDivs=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.className=='sysop_edit_line') divs.style.display= ( toggleSysopEdits.hidden ? 'none' : 'inline' );
  }
  toggleSysopEdits.hidden = ! toggleSysopEdits.hidden;
}

window.bundles={};

window.vandalColour = function(vandal) {
  var num=window.vandals;
  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.innerHTML==action + ' details' && document.links.href.indexOf('javascript:') == 0) {
      ++count; 
      eval(document.links.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/';
  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 > 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>' +
    ' ' +
  '<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=bundle; }
  window.bundles=z;
}

window.vandals={}

window.tryRollback=function(id) {
  var b=window.bundles;
  var vandal=b.editor;
  if (window.vandals==null) window.vandals=1;
  else window.vandals++;
  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="(/search/*?action=rollback*?from=(*)*?)".*?<br />(<span*>)?(.*?)(</span>)?<br /></td>');
    // match: useless
    // match: url (escaped)
    // match: last editor (escaped)
    // match: 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.split('+').join(' ');
    var lastSummary=match;
    // 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.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;
      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=;
  for (var i=0; i<nums.length; ++i) if (nums<10) nums='0'+nums;
  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;
  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) ) {
    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 = ;
      else if(key)     ta = ;
      else if(title)   ta = ;
    }
    // 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');
    recent2.addlilink(tb, url, name, id);
}

window.addMarvin=function() {
  recent2.addToolboxLink('http://en.wikipedia.org/User:Lupin/Filter_recent_changes', 'Filter recent changes', 'toolbox_filter_changes');
  recent2.addToolboxLink('http://en.wikipedia.org/User:Lupin/All_recent_changes', 'All recent changes', 'toolbox_all_changes');
  recent2.addToolboxLink('http://en.wikipedia.org/User:Lupin/Recent_IP_edits', 'Recent IP edits', 'toolbox_IP_edits');
  recent2.addToolboxLink('http://en.wikipedia.org/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/Filterrecentchanges','i').test(loc)) {
    recent2.filter_badwords=true;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/Allrecentchanges','i').test(loc)) {
    recent2.filter_badwords=false;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/RecentIPedits','i').test(loc)) {
    recent2.filter_anonsOnly=true;
    recent2.runOnce(marvin, 1000);
  }
  else if (RegExp('User:Lupin/Monitormywatchlist', '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)).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 = regDropSubpages.exec(ptitle);
  url = "http://en.wikipedia.org/search/?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/search/?title=Special%3ALog&page=" + ptitle;
 }
 
 tabs = document.getElementById('p-tb').getElementsByTagName('ul');
 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.href.substring(links.href.length-15) != '&action=history')
            continue;
        var unwatch = document.createElement('a');
        unwatch.href = "/search/?" + query_prefix + encodeURIComponent(links.title);
        unwatch.title = "Unwatch "+links.title;
        unwatch.appendChild(document.createTextNode("unwatch"));
        links.parentNode.insertBefore(unwatch, links.nextSibling);
        // kluge to handle case where "diff" is unlinked:
        var delim = links.previousSibling;
        delim = (delim.nodeType == 3 ? delim.nodeValue : "");
        links.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/search/?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }

/**************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
********************************************* VoA SCRIPTS START HERE **********************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
***************************************************************************************************************************
**************************************************************************************************************************/

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

//moves
Mvaluejsadmin = 'm';
//edits
Rvaluejsadmin = 'r';
//uploads
Uvaluejsadmin = 'u';

// </nowiki></pre>