Jump to content

User:AutomaticStrikeout/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
importScript('User:Ryan Vesey/sidebar.js');
importScript('User:NuclearWarfare/Mark-blocked script.js'); //Puts a strikethough in blocked users' signatures
importScript("User:GregU/dashes.js"); // Fixes dashes in an article
importScript("User:PleaseStand/userinfo.js"); // Puts information about user rights, edit count, gender, and activity time on the top of someone's user page
importScript('User:Lupin/popups.js'); //Ads Popups, I encourage you to test this out for a week or so.  It takes some getting used to but it's great
importScript('User:Equazcion/ActiveWatchers.js'); //shows a count of the number of watchers who are actively editing
importScript('User:קיפודנחש/TemplateParamWizard.js'); //Template Parameter Wizard (Amazing script, it puts a button on the edit toolbar that allows you to choose any template and it pulls up all of the parameters for that template for you to fill out)

// See [[User:Mr.Z-man/closeAFD]] for documentation
importScript('User:Timotheus Canens/displaymessage.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()) {
    displayMessage('<div style="color:red; font-size:120%">Your browser does not seem to support AJAX, which is required for the closeAFD script.</div>');
    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();
  displayMessage('<h3>Relisting '+closeAFD_PageName+'</h3><ul><li><b>Old log:</b> <a href="/wiki/'+encodeURI(oldlog)+'" title="'+oldlog+'">'+oldlog+'</a></li><li><b>New log:</b> <a href="/wiki/'+encodeURI(newlog)+'" title="'+newlog+'">'+newlog+'</a></li></ul><br /><input type="button" id="closeAFD_relist_button" name="closeAFD_relist_button" value="Submit" onclick="closeAFD_continue_relist(\''+newlog+'\', \''+oldlog+'\')" /><input type="button" id="closeAFD_cancel_relist_button" name="closeAFD_cancel_relist_button" value="Cancel" onclick="displayMessage(\'\')" />');
}
function closeAFD_continue_relist(newlog, oldlog) {
  displayMessage('<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"><b>Done (<a href="/wiki/'+encodeURI(closeAFD_PageName)+'?action=purge" title="'+closeAFD_PageName+'">Reload page</a>)</b></li></span></span>';
  AFDpage = closeAFD_getPageText(closeAFD_PageName);
  oldlogpage = closeAFD_getPageText(oldlog);
  newlogpage = closeAFD_getPageText(newlog);
  if (newlogpage == '' || oldlogpage == '') {
    displayMessage('<span style="color:red; font-size:120%">Log page doesn\'t seem to exist!</span>');
    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, "<!-- $1 -->");
  newlogreg = new RegExp("<!-- Add new entries to the TOP of the following list -->", "i");
  if (!newlogreg.test(newlogpage)) {
    displayMessage('<div style="color:red"><b><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.<br/>Unable to relist. Aborting.</b></div>');
    return;
  }
  newlogpage = newlogpage.replace(newlogreg, "<!-- Add new entries to the TOP of the following list -->\n{"+"{"+closeAFD_PageName+"}}<!--Relisted-->");
  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()) {
    displayMessage('<span style="color:red; font-size:120%">Your browser does not seem to support AJAX, which is required for the closeAFD script.</span>');
    return;
  }
  form = '<div id="closeAFD_initialform">'+
    '<h3>Closing '+closeAFD_PageName+'</h3>'+
    '<label for="closeAFD_reason">Additional closing rationale (optional):</label><br />'+
    '<input type="text" size="120" id="closeAFD_reason" name="closeAFD_reason" />'+
    '<label for="closeAFD_speedy">Speedy:</label><input type="checkbox" id="closeAFD_speedy" name="closeAFD_speedy" /><br /><br />'+
    '<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()" /><br />'+
    '<label for="closeAFD_deleteredir">Delete redirects:</label><input type="checkbox" id="closeAFD_deleteredir" name="closeAFD_deleteredir" />'+
    '<input type="hidden" value="0" id="closeAFD_dodelete" name="closeAFD_dodelete" /></div><div id="closeAFD_extra"></div>';
  displayMessage(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 += '<br /><label for="closeAFD_prompt">Target for '+type+': </label><input type="text" id="closeAFD_prompt" name="closeAFD_prompt" /><br />';
  if (type == 'redirect') {
    document.getElementById('closeAFD_extra').innerHTML += '<label for="closeAFD_delete_first">Delete before redirecting: </label><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 += '<br /><br /><label for="closeAFD_otherclose">Other: </label><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 == '') {
      displayMessage('<div style="color:red; font-size:120%">No target entered.</div>')
      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;
  }
  displayMessage('<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"><b>Done (<a href="/wiki/'+encodeURI(closeAFD_PageName)+'?action=purge" title="'+closeAFD_PageName+'">Reload page</a>)</b></li></span></span>';
  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,"");
  AFDpage = AFDpage.replace(/\[\[Category:Relisted AfD debates\|{{SUBPAGENAME}}\]\]/i,"");
  if (closeAFD_isAdmin) {
    AFDpage = "{"+"{subst:at}} '''"+close+"'''."+reason+' ~~'+'~~\n' + AFDpage + '\n{'+'{subst:ab}}';
  } else {
    AFDpage = "{"+"{subst:at}} '''"+close+"'''."+reason+' ([[Wikipedia:non-admin closure|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(/<!-- Please do not remove or change this AfD message until the issue is settled -->[\S\s]*?<!-- End of AfD message, feel free to edit beyond this point -->\n/, '');
  }
  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 + '</span>';
  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 = '<div style="color:red"><b>Edit failed on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a></b></div>. Error info:' +response['error']['code'] + ' : ' + response['error']['info'];
        }
      }
      catch(err) {
          document.getElementById('closeAFD_edit'+escape(title)).innerHTML = '<div style="color:red"><b>Edit failed on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a></b></div>';
      }
      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 + '</span>';
  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 = '<span style="color:red"><b>Deletion error on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>. Error info:' +response['error']['code'] + ' : ' + response['error']['info'] + '</b></span>';
          } else {
            closeAFD_deletePage(title, token, summary, false, true);
          }
        } else {
          if (retry) {
            document.getElementById('closeAFD_status').innerHTML += '<li><span style="color:red"><b>Deletion error on <a href="/wiki/'+encodeURI(title)+'" title="'+title+'">'+title+'</a>. Error info:' +response['error']['code'] + ' : ' + response['error']['info'] + '</b></span></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:Shubinator/DYKcheck.js');



function orangeBarOfDoom()
{
	var cookieResult = $.cookie("lastTalkpageView");
	if(cookieResult != null)
	{
		var escapedUsername = wgUserName.replace(/ /g, "_");
		if(wgPageName == "User_talk:"+ escapedUsername)
		{
			var d = new Date();
			$.cookie("lastTalkpageView", d.getTime(), {expires:365, path: '/'});
		}
		else
		{
			var data = {action: "query", prop:"revisions", format:"json", rvprop:"timestamp|user", rvlimit:"1", rvdir:"older", rvexcludeuser: wgUserName, titles: "User talk:"+wgUserName};
			$.post("/w/api.php", data, function(results)
			{
				var index = Object.keys(results.query.pages)[0];
				var lastUser = results.query.pages[index].revisions[0].user
				var lastTimestamp = Date.parse(results.query.pages[index].revisions[0].timestamp);
				if( cookieResult < lastTimestamp )
				{
					var orangeBarDiv = document.createElement("div");
					orangeBarDiv.innerHTML = 'You have <a href="/w/index.php?title=User_talk:'+escapedUsername+'&amp;redirect=no" title="User talk:'+wgUserName+'">new messages.</a> Last edit by '+lastUser+'.';
					orangeBarDiv.className = "usermessage";
					$("#contentSub").after(orangeBarDiv);
				}
			})
		}
	}
	else
	{
		var d = new Date();
		$.cookie("lastTalkpageView", d.getTime(), {expires:365, path: '/'});
	}
}
$(document).ready(orangeBarOfDoom);

function lowerNoPunct(s)
{
  return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}
 
addOnloadHook(function() {
  if(wgNamespaceNumber==0) return; //avoid article space, generally speaking
  var vs=
  "http://upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/15px-Symbol_support_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/15px-Symbol_keep_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/15px-Symbol_oppose_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_delete_vote.svg/15px-Symbol_delete_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/15px-Symbol_neutral_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/15px-Symbol_merge_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/15px-Symbol_move_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/15px-Symbol_redirect_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/15px-Symbol_opinion_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_comment_vote.svg/15px-Symbol_comment_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/15px-Symbol_unsupport_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/15px-Symbol_question.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/a/aa/Symbol_divide_vote.svg/15px-Symbol_divide_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/15px-Symbol_wait.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Face-grin.svg/15px-Face-grin.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Symbol_support2_vote.svg/15px-Symbol_support2_vote.svg.png#"+
  "http://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/15px-Symbol_no_support_vote.svg.png";
  var vt=vs.split("#");
  var la=new Array();
  la['support']=0; la['endorse']=0;
  la['keep']=1;
  la['oppose']=2; la['overturn']=2; la['object']=2;
  la['delete']=3;
  la['neutral']=4;
  la['merge']=5; la['upmerge']=5;
  la['move']=6; la['rename']=6; la['userfy']=6; la['transwiki']=6;
  la['redirect']=7;
  la['opinion']=8; la['relist']=8; la['subst']=8; la['salt']=8; la['change']=8; la['list']=8;
  // Note that icon 8 on the list is often used for debate-specific !votes
  la['comment']=9; la['update']=9; la['note']=9;
  la['delist']=10;
  la['question']=11;
  la['split']=12;
  la['wait']=13;
  la['bjaodn']=14;
  la['undelete']=15; la['restore']=15;
  la['close']=16;
 
  var btc=document.body.getElementsByTagName("B");
  i=btc.length;
  while(i--)
  {
    var j,k;
    j=btc[i].innerHTML.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
    k=0;
    var x="";
    while(k<j.length)
    {
      if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
       ||lowerNoPunct(j[k])=='no'||lowerNoPunct(j[k])=='without') break;
      var l=la[lowerNoPunct(j[k])];
      if(l!=undefined)
      {
        x+='<img src="'+vt[l]+'" alt="" /> '
      }
      k++;
    }
    if(x!="") btc[i].innerHTML=x+btc[i].innerHTML;
  }
});

importScript('User:Amalthea/userhighlighter.js');