User:Erik9/monobook.js

// // Cookie functions from User:GeorgeMoney/UserScripts/helpers/all // Warnings script modified from User:VoA/monobook.js

function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); }   return null; }

function createCookie(name,value,days) { if (days) { var date = new Date; date.setTime(date.getTime+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString; }   else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }

function eraseCookie(name) { createCookie(name,"",-1); }

//A clock that autoupdates //From the user scripts project, User:Voice of All/UTCclock.js addOnloadHook(loadclock) function loadclock { //monobook if (document.getElementById('pt-userpage')) {     var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0]; addlilink(toplinks, wgScript + '?title=' + wgPageName.replace(/&/g,'%26') + '&action=purge', '', 'utcdate'); } //cologneblue else if (document.getElementById('quickbar') && document.getElementById('quickbar').getElementsByTagName('h6')[0]) {      var toplinks = document.getElementById('quickbar'); addquickbarlink(wgScript + '?title=' + wgPageName.replace(/&/g,'%26') + '&action=purge', 'Current time', 'utcdate','Browse') }   showtime; CheckSuppressRC; }

function showtime {   var timerID; var now = new Date; var timeValue = now.toUTCString.substring(0,22) + " UTC"; if (document.getElementById('utcdate')) {document.getElementById('utcdate').firstChild.innerHTML = timeValue;} timerID = setTimeout('showtime', 1000); }

function storePageTitle { if(document.URL.indexOf('action=rollback') != -1) {   var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; createCookie("rolledbackPageTitle", document.URL.substr(document.URL.indexOf("title=") + "title=".length, document.URL.indexOf("&action=") - (document.URL.indexOf("title=") + "title=".length) ), 1); createCookie("userTalkPage", document.URL.substr(document.URL.indexOf("from=") + "from=".length, document.URL.indexOf("&token=") - (document.URL.indexOf("from=") + "from=".length) ), 1); tabs.appendChild(tnaddlilink('javascript:UwTestnAutoEdit(1, false)',"t1")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(1, false)',"v1")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(2, false)',"v2")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(3, false)',"v3")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(4, false)',"v4")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(1, false)',"n1")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(2, false)',"n2")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(3, false)',"n3")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(4, false)',"n4")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(0, false)',"p0")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(1, false)',"p1")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(2, false)',"p2")); } } addOnloadHook(storePageTitle);

//IMPORTS importScript('User:Voice_of_All/Addtabs/monobook.js'); importScript('User:Voice_of_All/UTCclock.js');

//

//

// User:Lupin/recent2.js - please include this line mw.loader.load(            'https://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js'             + '&action=raw&ctype=text/javascript&dontcountme=s'); //

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

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

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

function UwTestnAutoEdit(number, useCurrTalkPage) { if(useCurrTalkPage) {   var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); } else {   var title = "User_talk:" + readCookie("userTalkPage"); } location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=test" + number); }

function UwVandnAutoEdit(number, useCurrTalkPage) { if(useCurrTalkPage) {   var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); } else {   var title = "User_talk:" + readCookie("userTalkPage"); } location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=warn" + number); }

function UwNpovnAutoEdit(number, useCurrTalkPage) { if(useCurrTalkPage) {   var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); } else {   var title = "User_talk:" + readCookie("userTalkPage"); } location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=npov" + number); }

function BlpnAutoEdit(number, useCurrTalkPage) { if(useCurrTalkPage) {   var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free')); } else {   var title = "User_talk:" + readCookie("userTalkPage"); } location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=blp" + number); }

function UwTestn(number) { var IPnote = ''; if (document.title.split(' - ')[0].split('.').length == 4) {IPnote = "If this is an IP address, and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits. ";} var varticle = ''; if (location.href.indexOf('&vanarticle=') != -1) {varticle = ' to Category):/i,':$1:')) + '';} var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value +="====" + "Regarding edits made during   (UTC)" + varticle + "====" + "\n" + "" + readCookie("rolledbackPageTitle") + " " + IPnote + "~" + "~" + "~" + "~"; f.wpSummary.value = "uw-test" + number; f.wpSave.click; }

function UwVandn(number) { var IPnote = ''; if (document.title.split(' - ')[0].split('.').length == 4) {IPnote = "If this is an IP address, and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits. ";} var varticle = ''; if (location.href.indexOf('&vanarticle=') != -1) {varticle = ' to Category):/i,':$1:')) + '';} var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value +="====" + "Regarding edits made during   (UTC)" + varticle + "====" + "\n" + "" + readCookie("rolledbackPageTitle") + " " + IPnote + "~" + "~" + "~" + "~"; f.wpSummary.value = "uw-vand" + number; f.wpSave.click; }

function UwNpovn(number) { var IPnote = ''; if (document.title.split(' - ')[0].split('.').length == 4) {IPnote = "If this is an IP address, and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits. ";} var varticle = ''; if (location.href.indexOf('&vanarticle=') != -1) {varticle = ' to Category):/i,':$1:')) + '';} var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value +="====" + "Regarding edits made during   (UTC)" + varticle + "====" + "\n" + "" + readCookie("rolledbackPageTitle") + " " + IPnote + "~" + "~" + "~" + "~"; f.wpSummary.value = "uw-npov" + number; f.wpSave.click; }

function UwDeleten(number) { var IPnote = ''; if (document.title.split(' - ')[0].split('.').length == 4) {IPnote = "If this is an IP address, and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits. ";} var varticle = ''; if (location.href.indexOf('&vanarticle=') != -1) {varticle = ' to Category):/i,':$1:')) + '';} var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value +="====" + "Regarding edits made during   (UTC)" + varticle + "====" + "\n" + "" + readCookie("rolledbackPageTitle") + " " + IPnote + "~" + "~" + "~" + "~"; f.wpSummary.value = "uw-delete" + number; f.wpSave.click; }

function blpn(number) { var IPnote = ''; if (document.title.split(' - ')[0].split('.').length == 4) {IPnote = "If this is an IP address, and it is shared by multiple users, ignore this warning if you did not make any unconstructive edits. ";} var varticle = ''; if (location.href.indexOf('&vanarticle=') != -1) {varticle = ' to Category):/i,':$1:')) + '';} var f = document.editform, t = f.wpTextbox1; if (t.value.length > 0) t.value += '\n'; t.value +="====" + "Regarding edits made during   (UTC)" + varticle + "====" + "\n" + "" + readCookie("rolledbackPageTitle") + " " + IPnote + "~" + "~" + "~" + "~"; f.wpSummary.value = "blp" + number; f.wpSave.click; }

//Quick warning tabs addOnloadHook(add_testn_tabs); function add_testn_tabs { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; if (document.title.indexOf("Editing User talk:") != -1 && readCookie("RCToolsEnable") != "false") {  var f = document.editform, t = f.wpTextbox1; if (document.URL.lastIndexOf("&fakeaction=warn") != -1) {     UwVandn(document.URL[document.URL.lastIndexOf("&fakeaction=warn") + "&fakeaction=warn".length]); }  else if (document.URL.lastIndexOf("&fakeaction=test") != -1) {     UwTestn(document.URL[document.URL.lastIndexOf("&fakeaction=test") + "&fakeaction=test".length]); }  else if (document.URL.lastIndexOf("&fakeaction=npov") != -1) {     UwNpovn(document.URL[document.URL.lastIndexOf("&fakeaction=npov") + "&fakeaction=npov".length]); }  else if (document.URL.lastIndexOf("&fakeaction=blp") != -1) {     blpn(document.URL[document.URL.lastIndexOf("&fakeaction=blp") + "&fakeaction=blp".length]); }  else {       tabs.appendChild(tnaddlilink('javascript:UwTestn(1)',"t1")); tabs.appendChild(tnaddlilink('javascript:UwVandn(1)',"v1")); tabs.appendChild(tnaddlilink('javascript:UwVandn(2)',"v2")); tabs.appendChild(tnaddlilink('javascript:UwVandn(3)',"v3")); tabs.appendChild(tnaddlilink('javascript:UwVandn(4)',"v4")); tabs.appendChild(tnaddlilink('javascript:UwNpovn(1)',"n1")); tabs.appendChild(tnaddlilink('javascript:UwNpovn(2)',"n2")); tabs.appendChild(tnaddlilink('javascript:UwNpovn(3)',"n3")); tabs.appendChild(tnaddlilink('javascript:UwNpovn(4)',"n4")); tabs.appendChild(tnaddlilink('javascript:UwDeleten(1)',"d1")); tabs.appendChild(tnaddlilink('javascript:UwDeleten(2)',"d2")); tabs.appendChild(tnaddlilink('javascript:UwDeleten(3)',"d3")); tabs.appendChild(tnaddlilink('javascript:UwDeleten(4)',"d4")); tabs.appendChild(tnaddlilink('javascript:blpn(0)',"p0")); tabs.appendChild(tnaddlilink('javascript:blpn(1)',"p1")); tabs.appendChild(tnaddlilink('javascript:blpn(2)',"p2")); if(document.getElementById('ca-delete')) {       document.getElementById('ca-delete').firstChild.innerHTML = '[d]'; }       if(document.getElementById('ca-move')) {     document.getElementById('ca-move').firstChild.innerHTML = '[m]'; }       if(document.getElementById('ca-watch')) {     document.getElementById('ca-watch').firstChild.innerHTML = '[w]'; }       if(document.getElementById('ca-unwatch')) {     document.getElementById('ca-unwatch').firstChild.innerHTML = '[uw]'; }     if(document.getElementById('ca-edit')) {       document.getElementById('ca-edit').firstChild.innerHTML = 'Edit'; }     if(document.getElementById('ca-talk')) {       document.getElementById('ca-talk').firstChild.innerHTML = 'Talk'; }     if(document.getElementById('ca-protect')) {       document.getElementById('ca-protect').firstChild.innerHTML = 'P (off)'; }     if(document.getElementById('ca-unprotect')) {       document.getElementById('ca-unprotect').firstChild.innerHTML = 'P (on)'; }   }  }  else if (document.title.indexOf("User talk:") != -1 && document.title.indexOf("Revision history of") == -1 && readCookie("RCToolsEnable") != "false") {     tabs.appendChild(tnaddlilink('javascript:UwTestnAutoEdit(1, true)',"t1")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(1, true)',"v1")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(2, true)',"v2")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(3, true)',"v3")); tabs.appendChild(tnaddlilink('javascript:UwVandnAutoEdit(4, true)',"v4")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(1, true)',"n1")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(2, true)',"n2")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(3, true)',"n3")); tabs.appendChild(tnaddlilink('javascript:UwNpovnAutoEdit(4, true)',"n4")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(0, true)',"p0")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(1, true)',"p1")); tabs.appendChild(tnaddlilink('javascript:BlpnAutoEdit(2, true)',"p2")); } } //

// //Please leave the following line //user:Where/easy db //Start db script //modded by VoA addOnloadHook(function { //check if called from deletion request  if (document.title.indexOf("Editing ") != -1 && wgNamespaceNumber !=-1)  {    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)      return;    if (document.URL.lastIndexOf("&reason=off") != -1)    {      var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3");      var f = document.editform, t = f.wpTextbox1;      t.value = "\n" + t.value;      f.wpSummary.value = "JS: Requesting speedy deletion (CSD " + type + ")";      f.wpSave.click;      return;    }    else if (document.URL.lastIndexOf("&reason=on") != -1)    {      var type = prompt("Enter reason for speedy deletion");      var f = document.editform, t = f.wpTextbox1;      t.value = "\n" + t.value;      f.wpSummary.value = "JS: Requesting speedy deletion";      f.wpSave.click;      return;    }  }  if (window.location.href.search(/Special:|&action=/) != -1) return;

addTab("javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", ""); addTab("javascript:easyDb(1)", "db (reason)", "ca-db0", "Request speedy deletion with reason", ""); }); function easyDb(n) { if (n == 0)  {    //edit page    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=off");  }    if (n == 1)  {    //edit page    var title = document.title.substr(0, document.title.lastIndexOf(' - Wikipedia, the free'));    location.assign("/wikipedia/en/w/index.php?title=" + title + "&action=edit&fakeaction=huff&reason=on");  } }

function suppressRollback { for (var i in document.links) {   if (document.links[i].href.indexOf('action=rollback') != -1) {     document.links[i].href = ""; } } }

function CheckSuppressRC { var c1 = document.getElementById('column-one'); var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0]; if(readCookie("RCToolsEnable") == "false") {   tabs.appendChild(tnaddlilink('javascript:EnableRC',"+RC")); suppressRollback; } else if((document.title.indexOf("User talk:") == -1 || document.title.indexOf("Revision history of") != -1) && (document.URL.indexOf('action=rollback') == -1)) {   tabs.appendChild(tnaddlilink('javascript:SuppressRC',"-RC")); } }

function EnableRC { createCookie("RCToolsEnable", "true"); location.assign(document.URL); }

function SuppressRC { createCookie("RCToolsEnable", "false"); location.assign(document.URL); }

//ARV 2.0 from User:Lightdarkness/aiv.js // - // XMLHttpRequest support // - if (document.implementation.createDocument) { var gml_xmlparser = new DOMParser; }

function gml_XMLParse(string) { if (document.implementation.createDocument) { return gml_xmlparser.parseFromString(string, "text/xml"); } else if (window.ActiveXObject) { var gml_xmldoc = new ActiveXObject("Microsoft.XMLDOM"); gml_xmldoc.async = "false"; ret = gml_xmldoc.loadXML(string); if (!ret) return null; return gml_xmldoc.documentElement; } return null; }

var gml_xmlhttp;

function HTTPClient { var gml_http; if(window.XMLHttpRequest) { gml_http = new XMLHttpRequest; } else if (window.ActiveXObject) { try { gml_http = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { gml_http = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { gml_http = false; }   }  }  return gml_http; } var pageName; var AIVpageName = 'Wikipedia:Administrator_intervention_against_vandalism'; var section = '1'; var vandal; var reason;

function addlilinkAIV(url, name, id){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.id = id; li.appendChild(na); tabs.appendChild(li); return li; }

function AIV{ if (document.title.indexOf("User talk:") != -1){ username = location.href.split(':')[2]; if(!username){ username = document.getElementsByTagName('h1')[0].innerHTML.split(':')[1]; }   if (username.indexOf("&action=edit") != -1){ //remove &action=edit from username, only happens when editing user talk username = username.split('&')[0]; }   else if (username.indexOf("&action=submit") != -1){ //remove &action=submit from username, only happens after giving user a warning. username = username.split('&')[0]; }   if (username.indexOf("#") != -1){ //this removes any ancor that could possibly be in the URL bar, where we fetch the username from. username = username.split('#')[0]; }   //if there is an & in there, lets get rid of it    if (username.indexOf("&") != -1){ username = username.split('&')[0]; }   var test = username.split('.'); if(test[3]) { addlilinkAIV('javascript:AIVandal("' + username + '")', 'Report IP', 'td-report'); }   else { addlilinkAIV('javascript:AIVandal("' + username + '")', 'Report', 'td-report'); } }  if (document.title.indexOf("User contributions") != -1){ username = location.href.split('/')[7]; if(username == undefined || username == ""){ //if this is the case, then something is up     if(location.href.indexOf("&target=")){ //it looks like we came here from a target link, lets just take the username from that username = location.href.split('=')[2]; }   }    addlilinkAIV('javascript:AIVandal("' + username + '")', 'Report', 'td-report'); } }

function AIVandal(vandalU){ vandal = vandalU; if(vandal == document.getElementById('pt-userpage').getElementsByTagName('a')[0].innerHTML){ alert('You don\'t want to report yourself, do you?'); return; }     reason = prompt('Reason?:'); if(!reason) return; document.getElementById('bodyContent').innerHTML = 'Please wait' + '...'; gml_xmlhttp = HTTPClient; if (!gml_xmlhttp) return; document.getElementById('bodyContent').innerHTML += ' Grabbing page...'; gml_xmlhttp.open('GET', 'https://secure.wikimedia.org/wikipedia/en/w/index.php?title=' + AIVpageName + '&action=edit' + '&section=' + section + '', true); gml_xmlhttp.onreadystatechange = AIVMore; gml_xmlhttp.send(null); }

function AIVMore { if (gml_xmlhttp.readyState != 4){ document.getElementById('bodyContent').innerHTML += '.'; return } var form, newform, l;  // Insert the downloaded form in our current page, using // only hidden form inputs. doc = gml_XMLParse(gml_xmlhttp.responseText); form = doc.getElementById('editform');

var x; var t = form.wpTextbox1.value; myArray = t.split(" "); var add; add = true; document.getElementById('bodyContent').innerHTML += ' Searching for existing report...'; var test = "*"; for (x in myArray) {   myArray2 = myArray[x].split(/\n/); for (y in myArray2){ if(myArray2[y] == ''){ add = false; }     if(myArray2[y] == test){ add = false; }     if(myArray2[y] == ''){ add = false; }   }  }  if(add == true){ document.getElementById('bodyContent').innerHTML += ' No report found, adding...'; } else{ //alert('CSD tag found'); document.getElementById('bodyContent').innerHTML += ' Report found, will not add...'; return; } //let's do something expiremntal, to see if it's an IP address var test = username.split('.'); if(test[3]) { form.wpTextbox1.value += '* - ' + reason + ' --~' + '~' + '~' + '~'; }   else { form.wpTextbox1.value += '* - ' + reason + ' --~' + '~' + '~' + '~'; }

form.wpSummary.value = 'Reporting ' + vandal + ' using ARV 2.1.';

newform = document.createElement('form'); l = form.getElementsByTagName('textarea'); for (i = l.length; i--; ) { var t = document.createElement('input'); t.type = 'hidden'; t.name = l[i].name; t.value = l[i].value; newform.appendChild(t); } l = form.getElementsByTagName('input'); for (i = l.length; i--; ) { if (l[i].name == 'wpSummary') { l[i].value = 'Reporting ' + vandal + ' using ARV 2.1.'; } else if (l[i].name == 'wpMinoredit') { l[i].value = '1'; } else if (l[i].name == 'wpWatchthis') { if (!l[i].checked) continue; l[i].value = "on"; } else if (l[i].name == 'wpPreview') { continue; } else if (l[i].name == 'wpDiff') { continue; }   l[i].type = 'hidden'; newform.appendChild(l[i]); } newform.name = form.name; newform.method = form.method; newform.id = form.id; newform.action = form.action; document.getElementById('bodyContent').innerHTML += ' Submitting form...'; document.getElementById('bodyContent').appendChild(newform); // Submit the form newform.submit; }

addOnloadHook(AIV);

//modification of User:Mr.Z-man/closeAFD.js if (wgPageName.indexOf('Wikipedia:Articles_for_deletion/') != -1 && wgPageName.indexOf('Wikipedia:Articles_for_deletion/Log/200') == -1) { var closeAFD_PageName = wgPageName.replace(/_/g, ' '); var closeAFD_isAdmin = (wgUserGroups.toString.indexOf('sysop') != -1); var closeAFD_AJAXnumber = 0; var closeAFD_deletenredirect = false; var closeAFD_nomdate = null; var closeAFD_deletecount = 0; var closeAFD_redirectlimit; var closeAFD_redirtotal; var closeAFD_redircount = 0; function closeAFD_relist { if (!wfSupportsAjax) { jsMsg(' Your browser does not seem to support AJAX, which is required for the closeAFD script. '); return; } var today = new Date; var monthnames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); month = monthnames[today.getUTCMonth]; day = today.getUTCDate; year = today.getUTCFullYear; datestring = year + " " + month + " " + day; var newlog = "Wikipedia:Articles for deletion/Log/"+datestring; oldlog = closeAFD_getOldLog; jsMsg(' Relisting '+closeAFD_PageName+' Old log: '+oldlog+'New log: '+newlog+' '); } function closeAFD_continue_relist(newlog, oldlog) { jsMsg(''); document.getElementById('closeAFD_finish').innerHTML += '<span id="closeAFD_finished_wrapper"><span id="closeAFD_finished_main" style="display:none"><li id="closeAFD_done">Done (<a href="/wiki/'+encodeURI(closeAFD_PageName)+'?action=purge" title="'+closeAFD_PageName+'">Reload page</a>)</li> '; AFDpage = closeAFD_getPageText(closeAFD_PageName); oldlogpage = closeAFD_getPageText(oldlog); newlogpage = closeAFD_getPageText(newlog); if (newlogpage ==  || oldlogpage == ) { jsMsg(' Log page doesn\'t seem to exist! '); return; } var regexpagename = closeAFD_PageName.replace(/([\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\x7E])/g, "\\$1"); regexpagename = regexpagename.replace(/ /g, "[\\s_]"); var rplstr = new RegExp("(\\{\\{" + regexpagename + "\\}\\})", "gi"); oldlogpage = oldlogpage.replace(rplstr, ""); newlogreg = new RegExp("", "i"); if (!newlogreg.test(newlogpage)) { jsMsg(' <a href="/wiki/'+encodeURI(newlog)+'" title="'+newlog+'">'+newlog+'</a> is missing the <tt>&lt;&#33-- Add new entries to the TOP of the following list --&gt;</tt> above the AFD tranclusions! Please add it. Unable to relist. Aborting. '); return; } newlogpage = newlogpage.replace(newlogreg, "\n{"+"{"+closeAFD_PageName+"}}"); AFDpage += '\n{'+'{subst:relist}}'; AFDpage = AFDpage.replace(/Wikipedia:Articles for deletion\/Log\/\d{4} \D{4,9} \d{1,2}#/i, newlog+"#"); token = closeAFD_getToken(true); closeAFD_editPage(newlog, newlogpage, token, "Relisting " + closeAFD_PageName + ""); closeAFD_editPage(oldlog, oldlogpage, token, "Relisting " + closeAFD_PageName + ""); closeAFD_editPage(closeAFD_PageName, AFDpage, token, "Relisting debate"); document.getElementById('closeAFD_finished_main').style.display = ''; }

function closeAFD_init { if (!wfSupportsAjax) { jsMsg(' Your browser does not seem to support AJAX, which is required for the closeAFD script. '); return; } form = '<div id="closeAFD_initialform">'+ ' Closing '+closeAFD_PageName+' '+ '<label for="closeAFD_reason">Additional closing rationale (optional): <input type="text" id="closeAFD_reason" name="closeAFD_reason" />'+ '<label for="closeAFD_speedy">Speedy: <input type="checkbox" id="closeAFD_speedy" name="closeAFD_speedy" />

'+   '<input type="button" id="closeAFD_delete_button" name="closeAFD_delete_button" value="Delete" onclick="closeAFD_close(\'delete\')" />'+ '<input type="button" id="closeAFD_keep_button" name="closeAFD_keep_button" value="Keep" onclick="closeAFD_close(\'keep\')" />'+ '<input type="button" id="closeAFD_noconsensus_button" name="closeAFD_noconsensus_button" value="No consensus" onclick="closeAFD_close(\'no consensus\')" />'+ '<input type="button" id="closeAFD_redirect_button" name="closeAFD_redirect_button" value="Redirect" onclick="closeAFD_prompt(\'redirect\')" />'+ '<input type="button" id="closeAFD_merge_button" name="closeAFD_merge_button" value="Merge" onclick="closeAFD_prompt(\'merge\')" />'+ '<input type="button" id="closeAFD_other_button" name="closeAFD_other_button" value="Other" onclick="closeAFD_other" /> '+   '<label for="closeAFD_deleteredir">Delete redirects: <input type="checkbox" id="closeAFD_deleteredir" name="closeAFD_deleteredir" />'+ '<input type="hidden" value="0" id="closeAFD_dodelete" name="closeAFD_dodelete" /> <div id="closeAFD_extra"> '; jsMsg(form); if (!closeAFD_isAdmin) { document.getElementById('closeAFD_delete_button').disabled = true; document.getElementById('closeAFD_deleteredir').disabled = true; } } function closeAFD_prompt(type) { document.getElementById('closeAFD_extra').innerHTML += ' <label for="closeAFD_prompt">Target for '+type+': <input type="text" id="closeAFD_prompt" name="closeAFD_prompt" /> '; if (type == 'redirect') { document.getElementById('closeAFD_extra').innerHTML += '<label for="closeAFD_delete_first">Delete before redirecting: <input type="checkbox" id="closeAFD_delete_first" name="closeAFD_delete_first" />'; } document.getElementById('closeAFD_extra').innerHTML += '<input type="button" id="closeAFD_prompt_button" name="closeAFD_prompt_button" value="Submit" onclick="closeAFD_close(\''+type+'\')" />'; if (!closeAFD_isAdmin && type == 'redirect') { document.getElementById('closeAFD_delete_first').disabled = true; } } function closeAFD_other { document.getElementById('closeAFD_extra').innerHTML += '

<label for="closeAFD_otherclose">Other: <input type="text" id="closeAFD_otherclose" name="closeAFD_otherclose" />'+ '<input type="button" id="closeAFD_other_delete_button" name="closeAFD_other_delete_button" value="Delete article" onclick="closeAFD_otherdelete" />'+ '<input type="button" id="closeAFD_other_nodelete_button" name="closeAFD_other_nodelete_button" value="Don\'t delete" onclick="closeAFD_otherkeep" />'; if (!closeAFD_isAdmin) { document.getElementById('closeAFD_other_delete_button').disabled = true; } } function closeAFD_otherdelete { document.getElementById('closeAFD_dodelete').value = 1; close = document.getElementById('closeAFD_otherclose').value; closeAFD_close(close); } function closeAFD_otherkeep { close = document.getElementById('closeAFD_otherclose').value; closeAFD_close(close); } function closeAFD_close(close) { if (typeof(closeAFD_redirectlimit) == "undefined") { closeAFD_redirectlimit = 50; } deleteredirects = false; if (document.getElementById('closeAFD_deleteredir').checked) { deleteredirects = true; } closetype = close; var dodelete = false; if (closetype == "delete" || document.getElementById('closeAFD_dodelete').value == 1) { dodelete = true; } var reason = document.getElementById('closeAFD_reason').value; if (reason != '') { reason = ' '+reason; } if (closetype == "redirect" || closetype == "merge") { var target = document.getElementById('closeAFD_prompt').value; if (target == null || target == '') { jsMsg(' No target entered. ') return; }   close+= " to "+target+""; } if (closetype == "redirect" && document.getElementById('closeAFD_delete_first').checked == true) { dodelete = true; closeAFD_deletenredirect = target; } if (document.getElementById('closeAFD_speedy').checked == true) { close = "speedy "+close; } jsMsg('<ul id="closeAFD_status"></ul><ul id="closeAFD_finish"></ul>'); document.getElementById('closeAFD_finish').innerHTML += '<span id="closeAFD_finished_wrapper"><span id="closeAFD_finished_main" style="display:none"><li id="closeAFD_done">Done (<a href="/wiki/'+encodeURI(closeAFD_PageName)+'?action=purge" title="'+closeAFD_PageName+'">Reload page</a>)</li> '; var AFDpage = closeAFD_getPageText(closeAFD_PageName); closeAFD_nomdate = /\d{1,2} \D{4,9} \d{4} \(UTC\)/.exec(AFDpage); AFDpage = AFDpage.replace(/{\{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD\|(\w|\?)}}\n/i,""); if (closeAFD_isAdmin) { AFDpage = "{"+"{subst:at}} "+close+"."+reason+' '+'\n' + AFDpage + '\n{'+'{subst:ab}}'; } else { AFDpage = "{"+"{subst:at}} "+close+"."+reason+' (non-admin closure) '+'\n' + AFDpage + '\n{'+'{subst:ab}}'; } token = closeAFD_getToken(true); pagetitle = wgTitle.substring(wgTitle.indexOf('/')+1); debatename = pagetitle; if (pagetitle.indexOf("nomination)") != -1) {   pagetitle = pagetitle.replace(/ \([^\)\(]*? nomination\)\s*$/, );  }  closeAFD_editPage(closeAFD_PageName, AFDpage, token, "Closing debate, result was " + close);  var AFDlink = +closeAFD_PageName+'';  if (dodelete) {    if (deleteredirects) {      redirects = closeAFD_getRedirects(pagetitle);      if (redirects == "toomanyredir") {        document.getElementById('closeAFD_status').innerHTML += '<li>Number of redirects exceeds limit of '+closeAFD_redirectlimit+'</li>';      } else if (redirects == "noredir") {        document.getElementById('closeAFD_status').innerHTML += '<li>No redirects</li>';      } else {        closeAFD_deleteRedirects(pagetitle, redirects, token);      }    }    closeAFD_deletePage(pagetitle, encodeURIComponent(token), AFDlink, false, false);    closeAFD_deletePage("Talk:"+pagetitle, encodeURIComponent(token), AFDlink, false, false); } var articlepage = '' if (closetype != "redirect" && closetype != "delete" && !dodelete ) { articlepage = closeAFD_getPageText(pagetitle); articlepage = articlepage.replace(/[\S\s]*?\n/, ''); articlepage = articlepage.replace(/\{\{\s*(r|R)escue\s*(\|.*?)?\}\}/, ''); } if (closetype == "redirect") { articlepage = "#REDIRECT "+target+""; } if (!dodelete) { if (closeAFD_nomdate == null) { closeAFD_nomdate = prompt("Nomination date?", ''); }   var talkpage = ''; if (closetype != "redirect") { talkpage = closeAFD_getPageText("Talk:"+pagetitle); talkpage = "{"+"{oldafdfull| date = "+closeAFD_nomdate+" | result = "+close+" | page = "+pagetitle+" }}\n\n" + talkpage; } else { talkpage = "{"+"{oldafdfull| date = "+closeAFD_nomdate+" | result = "+close+" | page = "+pagetitle+" }}"; }   if (closetype == "merge") { var today = new Date; var monthnames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"); month = monthnames[today.getUTCMonth] day = today.getUTCDate if (day < 10) { day = "0"+day; }     year = today.getUTCFullYear; datestring = day + " " + month + " " + year; articlepage = "{"+"{afd-mergeto|"+target+"|"+debatename+"|"+datestring+"}}\n\n" + articlepage; var targettalkpage = closeAFD_getPageText("Talk:"+target); targettalkpage = "{"+"{afd-mergefrom|"+pagetitle+"|"+debatename+"|"+datestring+"}}\n\n" + targettalkpage; closeAFD_editPage("Talk:"+target, targettalkpage, token, AFDlink + " closed as " + close); }   closeAFD_editPage(pagetitle, articlepage, token, AFDlink + " closed as " + close); closeAFD_editPage("Talk:"+pagetitle, talkpage, token, AFDlink + " closed as " + close); } document.getElementById('closeAFD_finished_main').style.display = ''; }

function closeAFD_getPageText(title) { document.getElementById('closeAFD_status').innerHTML += '<li id="closeAFD_get'+escape(title)+'">Getting <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a></li>'; var req = sajax_init_object; req.open("GET", wgScriptPath + "/api.php?action=query&prop=revisions&rvprop=content&format=json&indexpageids=1&titles="+encodeURIComponent(title), false); req.send(null); var response = eval('(' + req.responseText + ')'); pageid = response['query']['pageids'][0]; if (pageid == "-1") { document.getElementById('closeAFD_get'+escape(title)).innerHTML = '<a class="new" href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a> does not exist'; delete req; return ''; } pagetext = response['query']['pages'][pageid]['revisions'][0]['*']; delete req; document.getElementById('closeAFD_get'+escape(title)).innerHTML = 'Got <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>'; return pagetext; } function closeAFD_getToken(show) { if (show) { document.getElementById('closeAFD_status').innerHTML += '<li id="closeAFD_gettoken">Getting token</li>'; } var req = sajax_init_object; req.open("GET", wgScriptPath + "/api.php?action=query&prop=info&indexpageids=1&intoken=edit&format=json&titles="+encodeURIComponent(closeAFD_PageName), false); req.send(null); var response = eval('(' + req.responseText + ')'); pageid = response['query']['pageids'][0]; token = response['query']['pages'][pageid]['edittoken']; delete req; if (show) { document.getElementById('closeAFD_gettoken').innerHTML = 'Got token'; } return token; } function closeAFD_getOldLog { var req = sajax_init_object; req.open("GET", wgScriptPath + "/api.php?action=query&format=json&list=embeddedin&eifilterredir=nonredirects&einamespace=4&bllimit=500&eititle="+encodeURIComponent(closeAFD_PageName), false); req.send(null); var response = eval('(' + req.responseText + ')'); var logpage = '' for (var i=0; i<response['query']['embeddedin'].length; i++) { if (response['query']['embeddedin'][i]['title'].indexOf('Wikipedia:Articles for deletion/Log/') != -1) { logpage = response['query']['embeddedin'][i]['title']; } }  delete req; return logpage; } function closeAFD_editPage(title, newtext, token, summary) { document.getElementById('closeAFD_finished_wrapper').innerHTML = '<span id="closeAFD_AJAX_finished_'+closeAFD_AJAXnumber+'" style="display:none">' + document.getElementById('closeAFD_finished_wrapper').innerHTML + ' '; var func_id = closeAFD_AJAXnumber; closeAFD_AJAXnumber++; document.getElementById('closeAFD_status').innerHTML += '<li id="closeAFD_edit'+escape(title)+'">Editing <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a></li>'; var req = sajax_init_object; var params = "action=edit&format=json&token="+encodeURIComponent(token)+"&title="+encodeURIComponent(title)+"&text="+encodeURIComponent(newtext)+"&notminor=1&unwatch=1&summary="+encodeURIComponent(summary); url = wgScriptPath + "/api.php"; req.open("POST", url, true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", params.length); req.setRequestHeader("Connection", "close"); req.onreadystatechange = function { if(req.readyState == 4 && req.status == 200) { response = eval('(' + req.responseText + ')'); try { if (response['edit']['result'] == "Success") { document.getElementById('closeAFD_edit'+escape(title)).innerHTML = 'Saved <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>'; } else { document.getElementById('closeAFD_edit'+escape(title)).innerHTML = ' Edit failed on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>. Error info:' +response['error']['code'] + ' : ' + response['error']['info']; }     }      catch(err) { document.getElementById('closeAFD_edit'+escape(title)).innerHTML = ' Edit failed on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a> '; }     document.getElementById('closeAFD_AJAX_finished_'+func_id).style.display = ''; delete req; } }  req.send(params) } function closeAFD_deletePage(title, token, summary, isredirect, retry) { document.getElementById('closeAFD_finished_wrapper').innerHTML = '<span id="closeAFD_AJAX_finished_'+closeAFD_AJAXnumber+'" style="display:none">' + document.getElementById('closeAFD_finished_wrapper').innerHTML + ' '; var func_id = closeAFD_AJAXnumber; closeAFD_AJAXnumber++; if (!isredirect && !retry) { document.getElementById('closeAFD_status').innerHTML += '<li id="closeAFD_delete'+escape(title)+'">Deleting <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a></li>'; } else if(!retry) { closeAFD_redircount++; thisredir = closeAFD_redircount document.getElementById('redirstart').style.display = ''; document.getElementById('redirstart').innerHTML = 'Deleting redirect ' + closeAFD_redircount + ' of ' + closeAFD_redirtotal; } var req = sajax_init_object; var params = "action=delete&format=json&token="+token+"&title="+encodeURIComponent(title)+"&reason="+encodeURIComponent(summary); url = wgScriptPath + "/api.php"; req.open("POST", url, true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.setRequestHeader("Content-length", params.length); req.setRequestHeader("Connection", "close"); req.onreadystatechange = function { if(req.readyState == 4 && req.status == 200) { response = eval('(' + req.responseText + ')'); try { if (response['delete']['title']) { if (!isredirect) { document.getElementById('closeAFD_delete'+escape(title)).innerHTML = 'Deleted <a class="new" href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>'; } else { document.getElementById('redirend').style.display = ''; document.getElementById('redirend').innerHTML = 'Deleted redirect ' + thisredir + ' of ' + closeAFD_redirtotal; }       }      }      catch(err) { if (response['error']['code'] == "missingtitle") { document.getElementById('closeAFD_delete'+escape(title)).innerHTML = '<a class="new" href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a> does not exist'; } else if(!isredirect) { if (retry) { document.getElementById('closeAFD_delete'+escape(title)).innerHTML = ' '''Deletion error on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>. Error info:' +response['error']['code'] + ' : ' + response['error']['info'] +  '; } else { closeAFD_deletePage(title, token, summary, false, true); }       } else { if (retry) { document.getElementById('closeAFD_status').innerHTML += '<li> '''Deletion error on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>. Error info:' +response['error']['code'] + ' : ' + response['error']['info'] +  </li>'; } else { closeAFD_deletePage(title, token, summary, true, true); }       }      }      document.getElementById('closeAFD_AJAX_finished_'+func_id).style.display = ''; delete req; if (!isredirect) { closeAFD_deletecount++; }     if (closeAFD_deletenredirect && closeAFD_deletecount == 2) { articletext = ''; articletext = "#REDIRECT "+closeAFD_deletenredirect+""; var AFDlink = +closeAFD_PageName+; token = closeAFD_getToken(false); closeAFD_editPage(title, articletext, token, AFDlink + " closed as redirect to "+closeAFD_deletenredirect+"") }   }  }  req.send(params) } function closeAFD_getRedirects(page) { document.getElementById('closeAFD_status').innerHTML += '<li id="closeAFD_getredir">Getting redirects</li>'; var url = wgScriptPath + "/api.php?action=query&format=json&action=query&list=backlinks&bltitle="+encodeURIComponent(page)+"&blfilterredir=redirects&bllimit="+closeAFD_redirectlimit var req = sajax_init_object; req.open("GET", url, false); req.send(null); var response = eval('(' + req.responseText + ')'); if (typeof(response['query-continue']) != "undefined") { return "toomanyredir"; } if (typeof(response['query']) == "undefined") { return "noredir"; } var redirects = new Array; for (var i=0; i<response['query']['backlinks'].length; i++) { redirects[i] = response['query']['backlinks'][i]['title']; } delete req; document.getElementById('closeAFD_getredir').innerHTML = 'Got '+redirects.length+' redirects'; closeAFD_redirtotal = redirects.length; return redirects; } function closeAFD_deleteRedirects(pagetitle, redirects, token) { summary = "Deleting redirects to \""+pagetitle+"\" after "+closeAFD_PageName+""; document.getElementById('closeAFD_status').innerHTML += '<li id="redirstart" style="display:none;"></li><li id="redirend" style="display:none;"></li>'; for (var i=0; i<closeAFD_redirtotal; i++) { setTimeout("closeAFD_deletePage('"+redirects[i].replace(/'/, "\'")/*'*/+"', '"+encodeURIComponent(token)+"', '"+summary+"', true, false)", 500*closeAFD_redircount ); } }

function closeAFD_addLink { mw.util.addPortletLink("p-cactions", "javascript:closeAFD_init", "Close", "ca-closeAFD", "Close AFD"); mw.util.addPortletLink("p-cactions", "javascript:closeAFD_relist", "Relist", "ca-closeAFD-relist", "Relist AFD"); }

addOnloadHook(closeAFD_addLink); }

importScript('User:John254/mass rollback.js');

//modification of User:Mr.Z-man/User:Mr.Z-man/rollbackSummary.js function rollbackSummary { var hasRollback = getElementsByClassName(document, "span", "mw-rollback-link"); if (hasRollback[0] && (document.title.indexOf("User contributions") != -1)) { mw.util.addPortletLink('p-cactions', 'javascript:setRollbackSummary', "rollback summary", "ca-rollbacksummary", "Set rollback link edit summary"); } } addOnloadHook(rollbackSummary); function setRollbackSummary { summary = prompt("Change the default rollback summary for rollback links on this page to:", ""); if (!summary) { for (var i in document.links) { if (document.links[i].href.indexOf('summary=') != -1) { document.links[i].href = document.links[i].href.substring(0, document.links[i].href.indexOf('summary=')-1); }   }  }  else { summary = "&summary=" + encodeURIComponent(summary); for (var i in document.links) { if (document.links[i].href.indexOf('action=rollback') != -1) { document.links[i].href += summary; }   }  } }

//modification of User:Gracenotes/rollback.js function addSumLink { var rbnode = [], diffnode, index = {}, gebcn = document.getElementsByClassName ? function(a, b, c) { return a.getElementsByClassName(c) } : getElementsByClassName; if (typeof rollbackLinksDisable == 'object' && rollbackLinksDisable instanceof Array) for (var i = 0; i < rollbackLinksDisable.length; i++) index[rollbackLinksDisable[i]] = 1; if (!('user' in index) && wgCanonicalSpecialPageName == "Contributions") rbnode = gebcn(document.getElementById("bodyContent"), "span", "mw-rollback-link"); else if (!('history' in index) && wgAction == "history") rbnode = gebcn(document.getElementById("pagehistory"), "span", "mw-rollback-link"); else if (!('diff' in index) && (diffnode = document.getElementById("mw-diff-ntitle2"))) rbnode = gebcn(diffnode, "span", "mw-rollback-link"); for (var i = 0, len = rbnode.length; i < len; i++) { addRollbackSummaryLink(rbnode[i]) } }

function confirmRollback { var url = this.href; var user = url.match(/[?&]from=([^&]*)/); if (!user) return; user = decodeURIComponent(user[1].replace(/\+/g, " ")); var summary = prompt("Enter a summary to use for rollback.\n\nLeave blank to use the default. $user will be replaced with \"" + user + "\".", "") if (summary == undefined) return false; else if (summary == "") return true; this.href += "&summary=" + encodeURIComponent(summary.replace(/\$user/g, user)); return true; };

function addRollbackSummaryLink(rbnode) { var rblink = rbnode.getElementsByTagName("a")[0] var alink = rblink.cloneNode(true); alink.className = ""; //don't confuse other scripts alink.firstChild.nodeValue = "sum"; alink.onclick = confirmRollback; rbnode.insertBefore(alink, rblink.nextSibling); rbnode.insertBefore(document.createTextNode(" | "), alink); } if (typeof rollbackLinksDisable == 'undefined') rollbackLinksDisable = [];

addOnloadHook(addSumLink);

//