User:Mo0/monobook.js

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Mo0 (talk | contribs) at 01:39, 14 January 2006 (Okay, another change). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Jump to navigation Jump to search
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.
// Big thanks to User:JesseW for leading me to:
// [[Wikipedia:WikiProject_User_scripts/Techniques#Onload_Structure]]
// and to User:Sasquatch for the if(document.get ... code
//
// Working version done: Nov 2 2005 @ 7:44 PM EST
// Shortens edit, protect, talk and delete tabs
//
// References:
// http://en.wikipedia.org/wiki/MediaWiki:Monobook.js
// User:JesseW/monobook.js --- User:Drini/monobook.js
// Mo0 just basically stole this version from User:RoyBoy's monobook.

//	<pre><nowiki>

//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
/////////////////////////////////////////
function addlilink(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;
}

// appends msg to the currently-editted page, sets the summary to summ,
// and marks or unmarks the Watch this page checkbox according to watch.
function edit_summary_watch(msg, summ, watch)
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += msg;
  f.wpSummary.value = summ;
}

function test()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "test" + "}} -" + " " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Thanks for testing out Wikipedia!";
}

function testn(number)
{
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "test" + number + "-n|" + page + "}} -" + " " + "~" + "~" + "~" + "~";
  if (t.value > 2)
    f.wpSummary.value = "Vandalism to [[" + page + "]] - warning " + number;
  else   
    f.wpSummary.value = "Please stop vandalising [[" + page + "]].";
}

function blankwarn(number)
{
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "test2a-n|" + page + "}} -" + " " + "~" + "~" + "~" + "~";
  f.wpSummary.value = "Please stop blanking [[" + page + "]].";
}

function bvn(number)
{
  var page = prompt("Vandalism to which article?")
  var f = document.editform, t = f.wpTextbox1;
    t.value += "{{subst:" + "bv-n|" + page + "}} -" + " " + "~" + "~" + "~" + "~" + "<br>";
  f.wpSummary.value = "Stop vandalising [[" + page + "]].";
}

// adds various tabs to call the above
function add_tabs()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];

  // Only add for pages with "Editing User talk:" somewhere in the title
  if (document.title.indexOf("Editing User talk:") != -1)
    {
      //change "move" tab to "m" for more room
      if(document.getElementById('ca-move'))
        document.getElementById('ca-move').firstChild.innerHTML = 'm';
      if(document.getElementById('ca-history'))
        document.getElementById('ca-history').firstChild.innerHTML = 'h';

      //change "user page" tab to "anon" to put them in their place, HA!
      if(document.getElementById('ca-nstab-user'))     
        document.getElementById('ca-nstab-user').firstChild.innerHTML = 'anon';

      //tabs.appendChild(addlilink('javascript:edit_summary_watch("{{" + "subst:anon}} -" + " " + "~" + "~" + "~" + "~", "{{" + "anon}}", false, 0)',"Anon"));
      //tabs.appendChild(addlilink('javascript:edit_summary_watch("{{" + "subst:welcome}} -" + " " + "~" + "~" + "~" + "~", "Welcome!", false, 0)',"Welcome!"));
     
      tabs.appendChild(addlilink('javascript:testn(1)',"1"));
      tabs.appendChild(addlilink('javascript:testn(2)',"t2"));
      tabs.appendChild(addlilink('javascript:blankwarn(2)',"2a"));
      tabs.appendChild(addlilink('javascript:testn(3)',"t3"));
      tabs.appendChild(addlilink('javascript:testn(4)',"t4"));
      tabs.appendChild(addlilink('javascript:bvn(1)',"bv"));
      tabs.appendChild(addlilink('javascript:edit_summary_watch("{{" + "subst:vblock" + "|" + prompt("Time?") + "|" + " " + "~" + "~" + "~" + "~" + "}}", "Blocked user!", true, 1)',"5"));
    }
	
if (document.title.indexOf("Editing Wikipedia:Articles for deletion") != -1)
    {
        tabs.appendChild(addlilink('javascript:closeafd("keep", "")', 'Keep', ''));
        tabs.appendChild(addlilink('javascript:closeafd("delete", "")', 'Delete', ''));
        tabs.appendChild(addlilink('javascript:closeafd(prompt("Result?"), "")', 'Other', ''));
    }
}

function addEditSection0() {
  ta['ca-edit-0'] = ['', 'Edit the zeroth section of this page'];
  if (!document.getElementById) return;
  x = document.getElementById('ca-edit');
  if(!x) return;
  y = document.createElement('LI');
  y.id = 'ca-edit-0';
  if (x.className == 'selected') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected';
    } else {
      x.className = 'selected istalk';
    }
  } else if (x.className == 'selected istalk') {
    if (/&action=edit&section=0$/.test(window.location.href)) {
      x.className = 'istalk';
      y.className = 'selected istalk';
    } else {
      y.className = 'istalk';
    }
  } else {
    y.className = x.className;
    x.className = 'istalk';
  }
  z = document.createElement('A');
  if (x.children) {
    z.href = x.children[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').children[1].insertBefore(y,x.nextSibling);
  } else {
    z.href = x.childNodes[0].href + '&section=0';
    z.appendChild(document.createTextNode('0'));
    y.appendChild(z);
    document.getElementById('p-cactions').childNodes[3].insertBefore(y,x.nextSibling);
  }
}

function shortTabs() {
  if(document.getElementById('ca-edit'))
    document.getElementById('ca-edit').firstChild.innerHTML = 'edit';

  if(document.getElementById('ca-protect'))
    document.getElementById('ca-protect').firstChild.innerHTML = 'pro';

  if(document.getElementById('ca-talk'))
    document.getElementById('ca-talk').firstChild.innerHTML = 'talk';

  if(document.getElementById('ca-delete'))
    document.getElementById('ca-delete').firstChild.innerHTML = 'del';

  if(document.getElementById('ca-unwatch'))
    document.getElementById('ca-unwatch').firstChild.innerHTML = 'unw';

  if(document.getElementById('ca-watch'))
    document.getElementById('ca-watch').firstChild.innerHTML = 'w';
}

// ***** Window Load ******

window.onload = Main;

function Main()
{
  shortTabs();
  add_tabs();

  if (document.title.indexOf("Editing User talk:") = -1)
    addEditSection0();
}

//	</nowiki></pre>