Jump to content

User:Anonymous Dissident/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Anonymous Dissident (talk | contribs) at 06:32, 28 December 2007 (add). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// [[User:Lupin/popups.js]]

importScript('User:Lupin/popups.js');

importScript('User:AzaToth/twinkle.js');

importScript("User:Lupin/recent2.js");

importScript('User:Animum/reset.js'); 

importscript('User:Lightmouse/monobook.js');

// [[User:Krimpet/CH2.js]]
importScript('User:Krimpet/CH2.js');

// [[User:Henrik/live-edit-counter]]
importScript('User:Henrik/js/live-edit-counter.js');

importScript('User:Tra/userwatchlist.js'); //[[User:Tra/userwatchlist.js]]

/**** afd helper ****/
document.write('<script type="text/javascript"' +
  'src="http://en.wikipedia.org/w/index.php?title=User:Jnothman/afd_helper/' +
  'script.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');

/* This is to keep track of who is using this extension: [[User:Jnothman/afd_helper/script.js]] */

afdh_signature = ' -- ~~'+'~';

//A helper function to add a button to one of the toolbars in the interface.
//An improved(I hope) version of [[Wikipedia:WikiProject User scripts/Scripts/Add LI link|addlilink]].
//[[User:JesseW/sig|JesseW, the juggling janitor]] 05:33, 8 November *2005 (UTC)

function addLink(where, url, name, id, title, key, after){
    //* where is the id of the toolbar where the button should be added;
    //   i.e. one of "p-cactions", "p-personal", "p-navigation", or "p-tb".
    //
    //* url is the URL which will be called when the button is clicked.
    //   javascript: urls can be used to do more complex things.
    //
    //* name is what will appear as the name of the button.
    //
    //* id is the id of the button; it's best to define one.  
    //   Use a prefix to make sure its unique. Optional.
    //
    //* title is the tooltip title that gives a longer description 
    //   of the button; if you define a accesskey, mention it here. Optional.
    //
    //* key is the char you want for the accesskey. Optional.
    //
    //* after is the id of the button you want to follow this one. Optional.
    //
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    if(id) li.id = id;
    li.appendChild(na);
    var tabs = document.getElementById(where).getElementsByTagName('ul')[0];
    if(after) {
	tabs.insertBefore(li,document.getElementById(after));
    } else {
	tabs.appendChild(li);
    }
    if(id) {
	if(key && title) { ta[id] = [key, title]; }
	else if(key) { ta[id] = [key, '']; }
	else if(title) { ta[id] = ['', title];} 
    }
    // re-render the title and accesskeys from existing code in wikibits.js
    akeytt();
    return li;
}

//this helps automate AfD closing by adding a 'close' tab to AfD debates
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]

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 = "{{subst:" + "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 = "{{subst:" + "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 = "{{subst:" + "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 = "{{subst:" + "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 = "{{subst:" + "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)
    {
      addLink('p-cactions', 'javascript:autoafd_result()', "close");
      addLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
  if (document.title.indexOf("Editing Talk:") != -1)
    {
      addLink('p-cactions', 'javascript:autoafd_keep()', "keep");
      addLink('p-cactions', 'javascript:autoafd_no_consensus()', "no consensus");
      addLink('p-cactions', 'javascript:autoafd_redirect()', "redirect");
      addLink('p-cactions', 'javascript:autoafd_merge()', "merge");
      addLink('p-cactions', 'javascript:autoafd_other()', "other");
    }
}

addOnloadHook(autoafd_add_afd_tabs);

//end AfD closing script

//csdreasonhelper - help insert deleted article reasons

function csdreasonhelper() {
   if (document.title.indexOf("Confirm deletion -") == 0) {
      var csdReasons = [
                         ['Nonsense', 'Nonsense ([[WP:CSD#G1|CSD G1]])'],
                         ['Test page', 'Test page ([[WP:CSD#G2|CSD G2]])'],
                         ['Vandalism', 'Vandalism ([[WP:CSD#G3|CSD G3]])'],
                         ['Recreated', 'Recreation of deleted material ([[WP:CSD#G4|CSD G4]])'],
                         ['Author blanked', 'Original author blanked the page ([[WP:CSD#G7|CSD G7]])'],
                         ['Talk', 'Talk page of a page that does not exist ([[WP:CSD#G8|CSD G8]])'],
                         ['Attack', 'Attack page ([[WP:CSD#G10|CSD G10]])'],
                         ['Spam', 'Blatant advertising ([[WP:CSD#G11|CSD G11]])'],
                         ['Copyvio', 'Copyright violation ([[WP:CSD#G12|CSD G12]])'],
                         ['No context', 'Very short article providing little or no context ([[WP:CSD#A1|CSD A1]])'],
                         ['No content', 'Contains no content whatsoever, consists only of links elsewhere, or a rephrasing of the title ([[WP:CSD#A3|CSD A3]])'],
                         ['NN bio', 'Article about a person, group of people, band, club, company or website that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. ([[WP:CSD#A7|CSD A7]])'],
                         ['NN band', 'Article about a band, singer, musician, or musical ensemble that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. See [[WP:MUSIC]]. ([[WP:CSD#A7|CSD A7]])'],
                         ['NN corp', 'Article about a company or corporation that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. ([[WP:CSD#A7|CSD A7]])'],
                         ['NN web', 'Article about a web site, blog, online forum, webcomic, podcast, or similar web content that does not assert the [[Wikipedia:Notability|importance or significance]] of the subject. See [[WP:WEB]]. ([[WP:CSD#A7|CSD A7]])'],
                         ['Redir none', 'Redirect to a non-existent page ([[WP:CSD#R1|CSD R1]])'],
                         ['Redir user', 'Redirect to a user page, user talk page, or talk page from the main/article space ([[WP:CSD#R2|CSD R2]])'],
                         ['Redir typo', 'Redirect page resulting from an implausible typo ([[WP:CSD#R3|CSD R3]])'],
                         ['User', 'User page or user subpage requested to be deleted by the user who created it ([[WP:CSD#U1|CSD U1]])'],
                       ];
   
      var csdBreak, csdLabel, csdSelect;
      csdBreak = document.createElement('br');
      csdLabel = document.createTextNode('Select CSD reason: ');
      csdSelect = document.createElement('select');
      csdSelect.id = "csd";
      csdSelect.onchange = new Function("document.getElementById('wpReason').value = this.options[this.selectedIndex].value");
      csdSelect.options[0] = new Option("Clear", "", true, true);
      for (var i = 0; i < csdReasons.length; i++) {
         csdSelect.options[i + 1] = new Option(csdReasons[i][0], csdReasons[i][1], false, false);
      }
      if (document.getElementById("Deletereason")) {
         document.getElementById("Deletereason").appendChild(csdBreak);
         document.getElementById("Deletereason").appendChild(csdLabel);
         document.getElementById("Deletereason").appendChild(csdSelect);
      }
   }
}

addOnloadHook(csdreasonhelper);

// end csdreasonhelper()