User:Voice of All/Bureaucrat/monobook.js
//
//
RfAshowlinks = 'false';
//
function jssubmitclose()
{
var form = document.getElementById('editform');
form.submit();
}
//archive recent promotions
function cratfinish()
{
if (location.href.search(/&jsaction=[SF]RFAunlist&target=/) !=-1)
{
var name = unescape(location.href.split('&target=')[1].split('&target2=')[0]);
var user = unescape(location.href.split('&target2=')[1]);
var listing = "{{" + name + "}}\n----";
var txt=document.editform.wpTextbox1;
if (txt.value.indexOf(listing) == -1){alert('RfA already removed.'); return;}
txt.value = txt.value.replace(listing,'');
alert(name + ' unlisted.');
if (location.href.indexOf('&jsaction=SRFAunlist') !=-1)
{
document.editform.wpSummary.value = "RfA closed, " + user + " promoted.";
}
else if (location.href.indexOf('&jsaction=FRFAunlist') !=-1)
{
document.editform.wpSummary.value = "RfA closed, no consensus to promote " + user + ".";
}
}
//add to recent promotion list
else if (location.href.indexOf('&jsaction=RFAsucadd&target') != -1)
{
var target = unescape(location.href.split('&target=')[1].split('&')[0]);
var name = '{{' + target + '}}' + '\n' + '----';
var txt = document.editform.wpTextbox1;
if (txt.value.indexOf('==Most recent successful nominations==') == -1) return;
var RFA_list = txt.value.split('==Most recent successful nominations==')[1];
var RFAs = RFA_list.match(/\{\{Wikipedia:Requests for adminship\/.+\}\}\n----/ig);
var lastRfA = RFAs[RFAs.length-1];
//remove last RfA
RFA_list=RFA_list.replace(lastRfA,'');
//add new one
txt.value = '==Most recent successful nominations==' + '\n' + name + RFA_list;
document.editform.wpSummary.value += 'Adding "' + target + '".';
//jssubmitclose();
}
//add to recent failure list
else if (location.href.indexOf('&jsaction=RFAfailadd&target=') != -1)
{
addTab("javascript:Alpha_userwait2()", "(Add)", "ca-add", "Add", "");
alert('Add "[NEW]" to the proper alphabetical location and press (add).');
var to_add = unescape(location.href.split('&target=')[1].split('&')[0]);
var name = to_add.split('')[1].split('')[0];
document.editform.wpSummary.value += 'Adding "' + name + '".';
}
}
//
var Alpha_user_done = 0;
function Alpha_userwait2()
{
var to_add = unescape(location.href.split('&target=')[1].split('&')[0]) + '\n';
var name = to_add.split('')[1].split('')[0];
if (Alpha_user_done == 1){alert('Already added.'); return;}
if (document.editform.wpTextbox1.value.indexOf('[NEW]') != -1){Alpha_user_done=1;}
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace('[NEW]',to_add);
}
function CHUlinks()
{
if(document.title.indexOf("Editing Wikipedia:Changing username (section)") == 0)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'Rename results', 'chclosefunc');
var chclosefunc = document.getElementById('chclosefunc').getElementsByTagName('ul')[0];
//Rename results
addlilink(chclosefunc, 'javascript:Cng_UName(1)', 'done', '');
addlilink(chclosefunc, 'javascript:Cng_UName(2)', 'not done', '');
}
if(document.title.indexOf("Editing Wikipedia:Changing username/Usurpations (section)") == 0)
{
var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
addlimenu(tabs, 'Rename results', 'chclosefunc');
var chclosefunc = document.getElementById('chclosefunc').getElementsByTagName('ul')[0];
//Rename results
addlilink(chclosefunc, 'javascript:Cng_Usurp()', 'status', '');
}
}
//
var Cng_UNamealready = 0;
function Cng_UName(type)
{
if (type == 1 && Cng_UNamealready != 1)
{
Cng_UNamealready=1;
document.editform.wpTextbox1.value += "\n" + ":{{done}} Done. ~~~~";
document.editform.wpSummary.value += "Complete.";
}
else if (type == 2 && Cng_UNamealready != 1)
{
Cng_UNamealready=1;
document.editform.wpTextbox1.value += "\n" + ":That username already exists. Please follow the instructions at the top of the page to select an unregistered username. ~~~~";
document.editform.wpSummary.value += ":{{not done}} Username already exists.";
}
}
function Cng_Usurp()
{
if (Cng_UNamealready != 1)
{
Cng_UNamealready=1;
document.editform.wpTextbox1.value += "\n{{cuu|notified=yes|email=no}}\n:~~~~";
document.editform.wpSummary.value += "Complete.";
}
}
//navdivs
var hide_rfa_div = '
';
function crathide()
{
if (location.href.search(/&oldid=|&diff=|&action=[^p]/) !=-1) return;
if (!RfAshowlinks){RfAshowlinks = 'false'}
if (mw.config.get('wgTitle') != "Requests for adminship" || mw.config.get('wgNamespaceNumber') != 4 || RfAshowlinks != 'true') return;
//kill table of contents
//if (document.getElementById('toc')) document.getElementById('toc').innerHTML = '';
var rawhtml = document.getElementById('bodyContent').innerHTML;
newhtml = rawhtml.replace(/(
<\/a><\/p>[\n\r])/igm,'
$1' + hide_rfa_div + '');
newhtml = newhtml.replace(/(
<\/a><\/p>[\n\r])/igm,'
$1');
newhtml = newhtml.replace(/(
<\/a><\/p>[\n\r])/igm,'$1');
newhtml = newhtml.replace(/(\(\d+\/\d+\/\d+\)).+ \d\d:\d\d.+ \(UTC\)( |)(<\/b>|)/ig,rfaTally);
document.getElementById('bodyContent').innerHTML = newhtml;
}
function rfaTally(match,tally)
{
var S = 1*tally.match(/\d+/g)[0]; var O = 1*tally.match(/\d+/g)[1]; var N = 1*tally.match(/\d+/g)[2];
perc = Math.round((100)*100*S/(S+O))/100; tperc = Math.round((100)*100*S/(S+O+N))/100;
var color = 'red';
if (perc > 90) color = 'green';
else if (perc > 80) color = 'darkgreen';
else if (perc > 70) color = 'darkorange';
else if (perc > 60) color = 'darkred';
poll = ' [' + perc + '%] (Conf:' + tperc + '%)';
var string = match + ' ' + poll + '
' + hide_rfa_div2 + '
';
return string;
}
//Get text in between two
heading
tag (eventually, h1, h3, ect...)
//the first input is the raw parent xml
//this assumes unique titles!
function getSectionBodytext(html,firstheading,nextheading,level)
{
var htag = '<' + level + '>';
var ehtag = '<\/' + level + '>';
var first_id = '
';
var next_id = '
';
var body_html = html.split(first_id)[1].split(next_id)[0];
var first_header = body_html.match(new RegExp(htag + '.+' + ehtag,''))[0];
var body_html = body_html.substr(body_html.indexOf(first_header));
return body_html;
}
function crattools()
{
if (document.title.indexOf('Editing Wikipedia:Requests for adminship/') != -1)
{
addTab("javascript:cratClose(1)", "(✓)", "ca-cratS", "Close as success", "");
addTab("javascript:cratClose(-1)", "(X)", "ca-cratF", "Close as failure", "");
}
else if (document.title.indexOf('Editing ') == -1 && document.title.indexOf('Wikipedia:Requests for adminship/') != -1 && location.href.indexOf('=history') == -1)
{
addTab("javascript:cratcomment()", "mess", "ca-cratI", "Leave user a new message", "");
}
}
function cratClose(type)
{
var txt = document.editform.wpTextbox1;
var RfAName = document.title.split(' (section)')[0].split(' - ')[0].split('Editing ')[1];
var user_name = RfAName;
if (txt.value.indexOf('{{User|') != -1)
{user_name = txt.value.split('{{User|')[1].split('}}')[0].split('}')[0]}
else if (txt.value.indexOf('{{user|') !=-1)
{user_name = txt.value.split('{{user|')[1].split('}}')[0].split('}')[0]}
var message = 'Closing ' + RfAName + '.';
var return_value = confirm(message);
if (return_value != true){return;}
if (document.editform.wpTextbox1.value.indexOf('The following discussion is preserved as an archive of') != -1)
{alert('Already closed!'); return;}
if (txt.value.indexOf('{{subst:rfab}') != -1){alert('Already closed!'); return;}
//both
var timeValue = new Date().toUTCString().replace(/GMT/, "(UTC)");
txt.value = txt.value.replace(/(ending|Scheduled to end) \d\d:\d\d, .+ \(UTC\)/i,'Ended ' + timeValue);
txt.value = txt.value.replace(/\}\}( |)Voice your opinion/ig,"}} Final");
txt.value = txt.value.replace(/\|action=edit\}\} (voice|vote|discuss|comment) .{1,20}\]/ig,"|action=edit}} Final]");
//passed
if (type == 1)
{
var deadlink = 'NOT_FOUND_LINK_YET';
txt.value = "{{subst:rfap}}" + "\n" + txt.value + "{{subst:rfab}}";
document.editform.wpSummary.value += "Closing successful nomination."; window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_adminship&action=edit&jsaction=SRFAunlist&target=' + escape(RfAName) + '&target2=' + escape(user_name),'BCratcloseRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Successful_adminship_candidacies&action=edit§ion=1&jsaction=RFAsucadd&target=' + escape(RfAName),'BCratcloserecentRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
cratpromote();
}
//failed
if (type == -1)
{
var deadlink = 'NOT_FOUND_LINK_YET';
if (txt.value.indexOf('{{subst:rfab}') != -1){alert('Already closed!'); return;}
document.editform.wpTextbox1.value = "{{subst:rfaf}}" + "\n" + document.editform.wpTextbox1.value + "{{subst:rfab}}";
document.editform.wpSummary.value += "Closing unsuccessful nomination.";
var tally = '';
if (txt.value.search(/\(\d+\/\d+\/\d+\)/) != -1)
{tally = txt.value.match(/\(\d+\/\d+\/\d+\)/)[0];}
var RfA_data = '*' + user_name + ', ' + timeValue + ' - consensus not reached at ' + tally;
var first_let = user_name.substring(0,1).toUpperCase();
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Requests_for_adminship&action=edit&jsaction=FRFAunlist&target=' + escape(RfAName) + '&target2=' + escape(user_name),'BCratcloseRFA:m' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
window.open('http://en.wikipedia.org/w/index.php?title=Wikipedia:Unsuccessful_adminship_candidacies/' + first_let + '&action=edit§ion=&jsaction=RFAfailadd&target=' + escape(RfA_data),'BCratcloserecentRFA:' + RfAName,'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
}
function alpha_sec(string)
{
var letter = string.substring(0,1).toLowerCase();
if (letter == 'a'){sec=1;}
else if (letter == 'b'){sec=2;}
else if (letter == 'c'){sec=3;}
else if (letter == 'd'){sec=4;}
else if (letter == 'e'){sec=5;}
else if (letter == 'f'){sec=6;}
else if (letter == 'g'){sec=7;}
else if (letter == 'h'){sec=8;}
else if (letter == 'i'){sec=9;}
else if (letter == 'j'){sec=10;}
else if (letter == 'k'){sec=11;}
else if (letter == 'l'){sec=12;}
else if (letter == 'm'){sec=13;}
else if (letter == 'n'){sec=14;}
else if (letter == 'o'){sec=15;}
else if (letter == 'p'){sec=16;}
else if (letter == 'q'){sec=17;}
else if (letter == 'r'){sec=18;}
else if (letter == 's'){sec=19;}
else if (letter == 't'){sec=20;}
else if (letter == 'u'){sec=21;}
else if (letter == 'v'){sec=22;}
else if (letter == 'w'){sec=23;}
else if (letter == 'x'){sec=24;}
else if (letter == 'y'){sec=25;}
else if (letter == 'z'){sec=26;}
else {sec=0;}
return sec;
}
function cratcomment()
{
var user_name = document.title.split('Wikipedia:Requests for adminship/')[1].split(' - ')[0];
if (document.getElementsByTagName('h3')[1])
{
if (document.getElementsByTagName('h3')[1].getElementsByTagName('strong')[0])
{user_name = document.getElementsByTagName('h3')[1].getElementsByTagName('strong')[0].innerHTML;}
else
{user_name = document.getElementsByTagName('h3')[1].innerHTML;}
}
window.open('http://en.wikipedia.org/w/index.php?title=User_talk:' + user_name + '&action=edit§ion=new',
'targetnameBCratclose',
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
function cratpromote()
{
var user_name = document.title.split('Wikipedia:Requests for adminship/')[1].split(' - ')[0];
if (document.editform.wpTextbox1.value.match(/\{\{user\|.+\}\}/ig))
{user_name = document.editform.wpTextbox1.value.split(/\{\{user\|/i)[1].split(/\}\}/)[0];}
window.open('http://en.wikipedia.org/w/index.php?title=Special%3AMakesysop&wpMakesysopUser=' + escape(user_name),
'BCratPromote:' + user_name,
'location=no,toolbar=no,status=no,directories=no,scrollbars=yes');
}
function cratstats_add()
{
if (location.href.indexOf('&action=history') ==-1 || document.title.search(/Wikipedia:Requests for (adminship|bureaucratship)\/|Wikipedia:Arbitration Committee Elections [^ ]+ \d\d\d\d\/Vote\//) !=0){return;}
var name = document.title.split(' - ')[0];
var url = 'http://en.wikipedia.org/w/index.php?title=' + name + '&action=history&limit=5000&jsaction=validate';
addTab(url, "✓?", "ca-vstats", "Voter statistics", "");
}
function crat_stats()
{
if (location.href.indexOf('&limit=5000&jsaction=validate') ==-1){return;}
//monobook
if (document.getElementById('bodyContent'))
{var body = document.getElementById('bodyContent');}
//cologneblue
else
{var body = document.getElementById('content');}
var l = body.getElementsByTagName('li');
var html = '
List of participants on this page:
';
var thenamelist = '|';
for (var i=l.length-1; i >= 0; i--)
{
if (l[i].innerHTML.indexOf('>) (last)') !=-1)
{var name = l[i].getElementsByTagName('a')[2].innerHTML; var date = l[i].getElementsByTagName('a')[1].innerHTML;}
else if (l[i].innerHTML.indexOf('(cur) (<') !=-1)
{var name = l[i].getElementsByTagName('a')[2].innerHTML; var date = l[i].getElementsByTagName('a')[1].innerHTML;}
else
{var name = l[i].getElementsByTagName('a')[3].innerHTML; var date = l[i].getElementsByTagName('a')[2].innerHTML;}
if (thenamelist.indexOf('|' + name + '|') ==-1)
{
thenamelist += name + '|';
var name_link = '' + name + '';
html += '\n' + '
' + name_link + ' -- ' + date + '';
}
}
body.innerHTML = body.innerHTML.split('')[0] + '' + '
';
//number our voters
var l = body.getElementsByTagName('li');
for (var i=0; i
{
var num = i+1;
l[i].innerHTML = '#' + num + ' ' + l[i].innerHTML;
}
consec_votercheck(0);
}
//
var voter_index = 0;
var name_user_vote = '';
function consec_votercheck(voter_index)
{
if (document.getElementById('voterstats').getElementsByTagName('li')[voter_index])
{
current_user_name = document.getElementById('voterstats').getElementsByTagName('li')[voter_index].getElementsByTagName('a')[0].innerHTML;
var URL = '/w/index.php?title=Special%3ALog&type=newusers&page=User:' + current_user_name + '&useskin=standard';
xml_http = HTTPClient();
xml_http.open("GET", URL, true);
xml_http.onreadystatechange = consec_votercheck_last;
xml_http.send(null);
}
else
{return;}
}
function consec_votercheck_last()
{
if (xml_http.readyState != 4) return;
var doc = xml_http.responseText.split("
")[1];
var date = '(older account)';
if (!doc) date = '(error)';
else if (doc.indexOf('