User:Dustihowe/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. The code below could contain malicious content capable of compromising your account; if your account appears to be compromised, it will be blocked. If you are unsure whether the code is safe, you can ask at the appropriate village pump.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
function autoafd_result()
{
  var close = prompt("Result of debate?")
  var f = document.editform, t = f.wpTextbox1;
  t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "~" + "~" + "~" + "~" + '\n' + '\n' + t.value;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
}
 
function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|~" + "~" + "~" + "~}}";
  f.wpSummary.value = "Relisting debate";
}
 
function autoafd_keep()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD";
}
 
function autoafd_no_consensus()
{
  var date = prompt("Nomination was made when?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''no consensus'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article survived AfD with no consensus";
}
 
function autoafd_redirect()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article redirected to [[" + redirect + "]] as per AfD";
}
 
function autoafd_merge()
{
  var date = prompt("Nomination was made when?")
  var redirect = prompt("Merge and redirect to?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''merge and redirect to [[" + redirect + "]]'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "Article merged and redirected to [[" + redirect + "]] as per AfD";
}
 
function autoafd_other()
{
  var date = prompt("Nomination was made when?")
  var result = prompt("Result was?")
  var votepage = prompt("Vote page is? (Enter 'd' for default.)")
  var f = document.editform, t = f.wpTextbox1;
 
    // If default votepage...
    if (votepage=="d")
      {
        var temp = document.editform.action.split("/w/index.php?title=");
        var temp = temp[1].split("&action=submit");
        var temp = temp[0].substring(5);
        var votepage = temp;
      }
 
  t.value = "{{" + "oldafdfull" + "|date=" + date + "|result='''" + result + "'''|votepage=" + votepage + "}}" + '\n' + '\n' + t.value;
  f.wpSummary.value = "AfDed; result was " + result;
}
 
function autoafd_add_afd_tabs()
{
  // Only add for pages with the right string somewhere in the title
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
      addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      addPortletLink('p-cactions', 'javascript:autoafd_keep()', "keep");
      addPortletLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
      addPortletLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
      addPortletLink('p-cactions', 'javascript:autoafd_merge()', "merge");
      addPortletLink('p-cactions', 'javascript:autoafd_other()', "other");
    }
}
 
addOnloadHook(autoafd_add_afd_tabs);
 
//end AfD closing script
 
//
 
//
 // Edit tools for the vandal whack-a-mole game
 // [[User:Kbh3rd/whackamole.js]] - please include this line
 //
 document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Kbh3rd/whackamole.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
//
//
 
 
 
// [[User:Lupin/popups.js]]
importScript('User:Lupin/popups.js');
popupFixRedirs=true;
popupRedlinkRemoval=true;
popupEditCounterTool="kate";
popupRevertSummaryPrompt=true;
 
//
//
function addSumLink() {
    var ntitle2 = document.getElementById("mw-diff-ntitle2")
    if (!ntitle2) return;
    var rbnode = getElementsByClassName(document.getElementById("mw-diff-ntitle2"), "span", "mw-rollback-link");
    if (rbnode.length != 0)
        addRollbackSummaryLink(rbnode[0]);
}
 
function confirmRollback() {
    var url = this.href;
    var user = url.match(/[?&]from=([^&]*)/);
    if (!user) return;
    var user = decodeURIComponent(user[1].replace("+", " "));
    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);
}
 
addOnloadHook(addSumLink);
//
//
 
// Feedback tab on article pages
// To-do, some sort of explanation thing, see what other people want
 
function feedbackTab () {
//Only load on articles, will add in a thing to limit to unregistered users later
if (wgNamespaceNumber == 0 ) {
  addPortletLink('p-cactions', wgScript + '?title=Talk:' + wgTitle + '&action=edit&section=new&feedback=1', "feedback", "ca-feedbacktab", "Leave feedback for this article");
   }
 
if (wgNamespaceNumber == 1 && document.URL.indexOf('feedback=1') != -1) {
  // Hide stuff that will just confuse the user and get in the way
  if (getElementsByClassName(document, "div", "mw-newarticletext")[0]) {
    getElementsByClassName(document, "div", "mw-newarticletext")[0].style.display = 'none';
  }
  document.getElementById('editform').style.visibility= 'hidden';
  document.getElementById('wpTextbox1').style.width = '0'
  document.getElementById('wpTextbox1').style.height = '0'
  document.getElementById('editpage-specialchars').style.display = 'none';
  document.getElementById('editpage-copywarn').style.display = 'none';
  document.getElementById('editpage-copywarn2').style.display = 'none';
  document.getElementById('editpage-copywarn3').style.display = 'none';
  document.getElementById('toolbar').style.display= 'none';
  document.getElementById('talkpagetext').style.display = 'none';
  document.getElementById('wpSummary').style.display = 'none';
  document.getElementById('wpSummaryLabel').style.display = 'none';
  getElementsByClassName(document, "div", "editButtons")[0].style.display = 'none';
 
  // Change the page appearance
  document.title = 'Feedback on ' + wgTitle + ' - Wikipedia, the free encyclopedia';
  document.getElementsByTagName('h1')[0].innerHTML = 'Feedback on ' + wgTitle;
 
  // Get the text of some important stuff we hid to insert later
  copyright = document.getElementById('editpage-copywarn').innerHTML;
  bottom = document.getElementById('editpage-copywarn2').innerHTML;
 
  //Create the form
  form = '<div style= \"margin: 0 0 1em; padding: .5em 1em; vertical-align: middle; border: solid #aaaaaa 1px\"><form id=\"feedbackform\" onsubmit=\"feedbackSubmit()\" action=\"javascript:feedbackDummyFunction()\">'+
    '<table>'+
    '<tr><td width=\"100\"><label for=\"quality\">Quality: </label></td>'+
              '<td width=\"500\"><input type=\"text\" style=\"width:100%\" id=\"quality\"></td></tr>'+
    '<tr><td width=\"100\"><label for=\"problems\">Problems: </label></td>'+
              '<td width=\"500\"><input type=\"text\" style=\"width:100%\" id=\"problems\"></td></tr>'+
    '<tr><td width=\"100\"><label for=\"suggestions\">Suggestions: </label></td>'+
              '<td width=\"500\"><input type=\"text\" style=\"width:100%\" id=\"suggestions\"></td></tr>'+
    '<tr><td width=\"100\"><label for=\"comments\">Comments: </label></td>'+
              '<td width=\"500\"><input type=\"text\" style=\"width:100%\" id=\"comments\"></td></tr>'+
    '<tr><td width=\"100\"><label for=\"sources\">Sources: </label></td>'+
              '<td width=\"500\"><input type=\"text\" style=\"width:100%\" id=\"sources\"></td></tr>'+
    '<input type=\"submit\" value=\"Submit\">'+
    '<tr></table></tr>'+
 '</form></div><br/>';
  form += copyright;
  form += bottom;
 
  // Add the form
  document.getElementById('wikiPreview').innerHTML += form;
 
   }      
}
 
function feedbackSubmit() { //Intercept the form submit and put stuff in the edit box
  var feed = document.getElementById('feedbackform');
  q = feed.quality.value;
  p = feed.problems.value;
  sug = feed.suggestions.value;
  c = feed.comments.value;
  sou = feed.sources.value;
 
  text = '\'\'\'Quality:\'\'\' ' + q + '\n\n'+ 
'\'\'\'Problems:\'\'\' ' + p + '\n\n'+ 
'\'\'\'Suggestions:\'\'\' ' + sug + '\n\n'+ 
'\'\'\'Comments:\'\'\' ' + c + '\n\n'+ 
'\'\'\'Sources:\'\'\' ' + sou + '\n\n-- ~~'+'~~';
 
  // Save the page
  document.getElementById('wpSummary').value = 'Article Feedback';
  document.getElementById('wpTextbox1').value = text;
  document.editform.wpSave.click()
}
 
// Setting the form action to the talk page URL sends us to the page before we save,
// an empty function will save the page normally and provide an anchor to the new section.
// Could probably put an alert() or something here, but that would just be annoying.
function feedbackDummyFunction() {
}
 
//Please leave the following line
//[[user:Where/easy db]], maintained by [[User:MER-C]]
//Start db script
 
addOnloadHook(function()
{
  //check if called from deletion request
  if (document.title.indexOf("Editing ") != -1)
  {
    if (document.URL.lastIndexOf("&fakeaction=huff") == -1)
      return;
    // does the page exist?
    if (wgCurRevisionId == false)
    {
      alert("The page has already been deleted.");
      return;
    }
    if (document.URL.lastIndexOf("&reason=off") != -1)
    {
      var type = prompt("Enter criteria for speedy deletion, e.g. A1, G3");
      if (type == null)
        return;
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{" + "{db-" + type.toLowerCase() + "}}\n" + t.value;
      f.wpSummary.value = "JS: Requesting speedy deletion ([[WP:CSD#" + type + "|CSD " + type.toUpperCase() + "]])";
      f.wpSave.click();
      return;
    }
    else if (document.URL.lastIndexOf("&reason=on") != -1)
    {
      var type = prompt("Enter reason for speedy deletion");
      if (type == null)
        return;
      var f = document.editform, t = f.wpTextbox1;
      t.value = "{" + "{db|" + type + "}}\n" + t.value;
      f.wpSummary.value = "JS: Requesting speedy deletion";
      f.wpSave.click();
      return;
    }
  }
  if (wgCanonicalNamespace == "Special")
    return;
 
  addPortletLink("p-cactions", "javascript:easyDb(0)", "db (csd)", "ca-db0", "Request speedy deletion according to WP:CSD", "");
  addPortletLink("p-cactions", "javascript:easyDb(1)", "db (reason)", "ca-db1", "Request speedy deletion with reason", "");
});
 
function easyDb(n)
{
  var title = wgPageName.replace("&", "%26").replace("+", "%2B");
  if (n == 0)
    location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=off&title=" + title);
 
  if (n == 1)
    location.assign("/w/index.php?&action=edit&fakeaction=huff&reason=on&title=" + title);
}
 
 
//End db script
//
 
// [[User:Henrik/live-edit-counter]]
importScript('User:Henrik/js/live-edit-counter.js');
 
//
 
/* Watchlist bolder ([[User:Ais523/watchlistbolder.js]], a stripped-down version of [[User:Ais523/watchlistnotifier.js]])
   This conflicts with the watchlistnotifier. On the request of [[User:Rockfang]]. */
//<pre><nowiki>
 
var wmwpajax;
// From [[WP:US]] mainpage (wpajax renamed to wmwpajax)
wmwpajax={
        download:function(bundle) {
                // mandatory: bundle.url
                // optional:  bundle.onSuccess (xmlhttprequest, bundle)
                // optional:  bundle.onFailure (xmlhttprequest, bundle)
                // optional:  bundle.otherStuff OK too, passed to onSuccess and onFailure
 
                var x = window.XMLHttpRequest ? new XMLHttpRequest()
                : window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP")
                : false;
 
                if (x) {
                        x.onreadystatechange=function() {
                                x.readyState==4 && wmwpajax.downloadComplete(x,bundle);
                        };
                        x.open("GET",bundle.url,true);
                        x.send(null); 
                }
                return x;
        },
 
        downloadComplete:function(x,bundle) {
                x.status==200 && ( bundle.onSuccess && bundle.onSuccess(x,bundle) || true )
                || ( bundle.onFailure && bundle.onFailure(x,bundle) || alert(x.statusText+': '+bundle.url));
        }
};
 
// Example:
// function dlComplete(xmlreq, data) {
//      alert(data.message + xmlreq.responseText);
// }
//  wmwpajax.download({url:'http://en.wikipedia.org/w/index.php?title=Thresher&action=raw', 
//                   onSuccess: dlComplete, message: "Here's what we got:\n\n" });
 
// End of [[WP:US]] quote
 
function wmWatchEditFound(xmlreq, data) {
  var watchrev, watchsum, watchrevold, watchpage, junk;
  if(wgPageName == "Special:Watchlist")
  {
    if(xmlreq.responseText.indexOf('revid=')==-1)
    {
      document.getElementById('contentSub').innerHTML+=
        "<div class='watchlistnotify'>(<i>watchlistnotifier can't determine whether a "+
        "watched page has changed<i>)</div>";
      return;
    }
    watchrev=xmlreq.responseText.split('revid="')[1].split('"')[0];
    try
    {
      watchrevold=document.cookie.split('ais523wmwatchrev=')[1].split('.')[0];
    }
    catch(junk) {watchrevold=0;}
    document.cookie="ais523wmwatchrev="+watchrev+".; path=/";
    var aas=document.getElementById('bodyContent').getElementsByTagName('a');
    var i=aas.length;
    while(i--)
    {
      if(aas[i].href.indexOf('diff=')!=-1&&watchrevold)
        if(+(aas[i].href.split('diff=')[1].split('&')[0])>watchrevold)
          aas[i].parentNode.style.fontWeight='bold';
    }
  }
}
 
addOnloadHook(function() {
  /* Find the top item in the watchlist, and its edit summary. We only need one item, so
     set the limit to 1 to ease the load on the server. */
  if(wgPageName == "Special:Watchlist")
    wmwpajax.download({url:'http://en.wikipedia.org/w/api.php?action=query&list=watchlist&wllimit=1&'+
      'wldir=older&format=xml&wlprop=comment|ids|title', onSuccess: wmWatchEditFound});
});
// </nowiki></pre>
// [[Category:Wikipedia scripts]]
 
//
//
importScript('User:AzaToth/twinkle.js');
 
//
//
 
importScript('User:Ioeth/friendly.js');