User:70...yes, 70/monobook.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// This needs to change depending on skin used.
function add_link(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

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

  var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
  tabs.appendChild(li);
}
function strip_namespace(target)
{
  var colon = target.indexOf(':');
  if (colon != -1)
    {
      var spaces = new Array('User', 'Wikipedia', 'Image', 'MediaWiki', 'Template', 'Help', 'Category');
      var ns = target.substring(0, colon);
      if (ns == '' || ns == 'Talk')
        return target.substring(colon + 1);
      else
        for (var i = 0; i < spaces.length; ++i)
          {
            if (ns == spaces[i]
                || ns == spaces[i] + '_talk')
              return target.substring(colon + 1);
          }
    }

  return target;
}

$(addLinkConvtab)
function addLinkConvtab()
{
if (document.title.indexOf('Editing ') !=0){return;}
addTab("javascript:lowercase_link_starts()", "U->L lnks", "ca-clinks", "Non-proper noun links", "");
}

function lowercase_link_starts()
{
var link_reg = /\[\[([^\]])(([^\]])+)\]\]/g;
document.editform.wpTextbox1.value = document.editform.wpTextbox1.value.replace(link_reg,non_proper_case);
document.editform.wpSummary.value = 'JS: "[[Link]]" --> "[[link]]".';
}

function non_proper_case(match,f_let,rest)
{
f_let = f_let.toLowerCase();
var string = '[[' + f_let + rest + ']]';
return string;
}

function vfd()
{
  document.editform.wpTextbox1.value = '{{' + 'subst:vfd}}\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'vfd';

  var target = document.editform.action;
  target = target.substring(target.indexOf('title=') + 6,
                            target.lastIndexOf('&action=submit'));

  var months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
  var date = new Date();
  date = date.getUTCFullYear() + '_' + months[date.getUTCMonth()] + '_' + date.getUTCDate();

  var pagename = strip_namespace(target);

  window.open('/w/index.php?title=Wikipedia:Votes_for_deletion/' + pagename + '&action=edit&fakeaction=vfdsub&faketarget=' + target,
              'Vfd ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
  window.open('/w/index.php?title=Wikipedia:Votes_for_deletion/Log/' + date + '&action=edit&fakeaction=vfdlist&faketarget=' + pagename,
              'VfdLog ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}

function autovfd()
{
  if (document.title.indexOf('Editing ') == 0)
    {
      var action = '';
      var target = '';
      if (location.search)
        {
          var l = location.search.substring(1).split('&');
          for (var i = 0; i < l.length; ++i)
            {
              var eq = l[i].indexOf('=');
              var name = l[i].substring(0, eq);
              if (name == 'fakeaction')
                action = l[i].substring(eq + 1);
              else if (name == 'faketarget')
                target = unescape(l[i].substring(eq + 1)).replace(/_/g, ' ');
            }
        }

      if (action == 'vfdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'Wikipedia:Votes for deletion/' + target + '}}\n';
          document.editform.wpSummary.value = '[[Wikipedia:Votes for deletion/' + target + ']]';
        }
      else if (action == 'vfdsub')
        {
          if (document.editform.wpTextbox1.value.length > 0)
            {
              target = document.editform.action;
              target = unescape(target.substring(target.indexOf('title=') + 6, target.lastIndexOf('&action=submit'))).replace(/_/g, ' ');
              window.alert("There's an old vfd at the default location already.\n\n" +
                           'Please either move it out of the way (and update existing links to it), or file the Vfd by hand in another location (such as [[' + target + ' (2)]]).');
            }
          else
            document.editform.wpTextbox1.value += '===[[' + target + ']]===\n' +
              'Reason for nomination. ~~' + '~~\n*\n*\n*\n';
        }
      else
        add_link('javascript:vfd()', 'Vfd');
    }
}

if (window.addEventListener) 
  window.addEventListener('load', autovfd, false);
else if (window.attachEvent) 
  window.attachEvent('onload', autovfd);
//<pre>
function add_link(url, name)
{
  //replace_editing_help(url, name);    // remove the "//" at the start of this line to replace the "editing help" under the edit window with the links
  //before_editbox(url, name);          // remove the "//" at the start of this line to place the links before the editing box

  //the following options are skin-specific.
  monobook_tab(url, name);            // remove the "//" at the start of this line to place the links in tabs in the monobook skin
  //monobook_toolbox(url, name);        // remove the "//" at the start of this line to place the links in the toolbox in the monobook skin
  //classic_header(url, name);          // remove the "//" at the start of this line to place the links in the header in the classic skin
  //classic_quickbar(url, name);        // remove the "//" at the start of this line to place the links in the quickbar in the classic skin
  //nostalgia_header(url, name);        // remove the "//" at the start of this line to place the links in the header in the nostalgia skin
  //cologneblue_quickbar(url, name);    // remove the "//" at the start of this line to place the links in the quickbar in the cologne blue skin
}

function before_editbox(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var form = document.editform;
  var x;
  for (x = form.firstChild; x; x = x.nextSibling)
    if (x.tagName == 'BR')
      {
        form.insertBefore(document.createTextNode(' | '), x);
        form.insertBefore(na, x);
        break;
      }
    else if (x.tagName == 'TEXTAREA')
      {
        form.insertBefore(na, x);
        form.insertBefore(document.createElement('br'), x);
        break;
      }
}

function replace_editing_help(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var form = document.editform;
  var em = form.getElementsByTagName('em');
  if (em.length > 1)
    form.replaceChild(na, em[1]);       // we haven't yet removed the "editing help" link, so replace it
  else
    {
      // either there's a br and a list of templates, or the editpage-copywarn div
      var x;
      for (x = em[0]; x && x.tagName != "BR" && x.tagName != "DIV"; x = x.nextSibling);
      if (!x)
        { // didn't find anything! so just append
          form.appendChild(document.createTextNode(' | '));
          form.appendChild(na);
        }
      else
        {
          form.insertBefore(document.createTextNode(' | '), x);
          form.insertBefore(na, x);
        }
    }
}

function monobook_tab(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var li = document.createElement('li');
  li.appendChild(na);
  document.getElementById('p-cactions').getElementsByTagName('ul')[0].appendChild(li);
}

function monobook_toolbox(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var li = document.createElement('li');
  li.appendChild(na);
  document.getElementById('p-tb').getElementsByTagName('ul')[0].appendChild(li);
}

function classic_header(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var td = document.getElementById('topbar').getElementsByTagName('table')[0].getElementsByTagName('td')[1].getElementsByTagName('p')[0];

  if (td.hasChildNodes())
    td.appendChild(document.createTextNode(' | '));
  td.appendChild(na);
}

function classic_quickbar(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  document.getElementById('quickbar').appendChild(na);
}

function nostalgia_header(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var bar = document.getElementById('topbar');
  var br = bar.getElementsByTagName('br')[1];
  bar.insertBefore(document.createTextNode(' | '), br);
  bar.insertBefore(na, br);
}

function cologneblue_quickbar(url, name)
{
  var na = document.createElement('a');
  na.setAttribute('href', url);
  na.appendChild(document.createTextNode(name));

  var qb = document.getElementById("quickbar");
  qb.appendChild(na);
  qb.appendChild(document.createElement('br'));
}

function sig()
{
  return ' ~~' + '~~';
}

// End of generic code

function transwiki_log()
{
  var title = prompt("Title?");
  if (title)
    {
      var target = prompt("To project?")
      if (target)
        {
          if (target == "k" || target == "K" || target == "d" || target == "D")
            target = "wikt";
          else if (target == "s" || target == "S")
            target = "wikisource";
          else if (target == "c" || target == "C")
            target = "commons";

          var txt = document.editform.wpTextbox1;
          var vfdd = prompt("Vfd at? (y/Y for [[Wikipedia:Votes for deletion/" + title + "]], or empty for none");
          if (vfdd == "y" || vfd == "Y")
            vfdd = " ([[Wikipedia:Votes for deletion/" + title + "|VfD]])";
          else if (vfdd == "n" || vfd == "N" || vfd == "")
            vfdd = "";
          else
            vfdd = " ([[Wikipedia:Votes for deletion/" + vfdd + "|VfD]])";
          txt.value += "*[[" + title + "]] &rarr; [[" + target + ":Transwiki:" + title + "]]" + sig() + vfdd;
          document.editform.wpSummary.value = "[[" + title + "]] transwikied to [[" + target + ":Transwiki:" + title + "]]" + vfdd;
        }
    }
}

function transwiki_to()
{
  var target = prompt("Transwiki to?\nwiKt/News/Books/Source/Commons/Meta/Quote");
  if (target == "k" || target == "K" || target == "d" || target == "D")
    target = "en.wiktionary";
  else if (target == "n" || target == "N")
    target = "en.wikinews";
  else if (target == "b" || target == "B")
    target = "en.wikibooks";
  else if (target == "s" || target == "S")
    target = "wikisource";
  else if (target == "c" || target == "C")
    target = "commons.wikimedia";
  else if (target == "m" || target == "M")
    target = "meta.wikimedia";
  else if (target == "q" || target == "Q")
    target = "en.wikiquote";
  else
    {
      window.alert("Unknown target.");
      return;
    }

  var url = new String(document.location);
  url = url.replace(/en\.wikipedia/, target);
  url = url.replace(/index\.php\?title=/, "index.php?title=Transwiki:");
  window.location = url;
}

function onload_transwiki()
{
  if (document.title.indexOf("Editing ") == 0)
    {
      if (document.title.indexOf("Editing Wikipedia:Transwiki log") == 0)
        add_link('javascript:transwiki_log()', 'Log entry');
      else
        add_link('javascript:transwiki_to()', 'TranswikiTo');
    }
  add_link("/wiki/Wikipedia:Transwiki log", 'Transwiki log');       // remove the "//" from the start of this line to add a link to the transwiki log.  You may want to use a specific add_link function instead, e.g. monobook_toolbox, so it doesn't appear in the same place as the editting links.
}

function do_onload()
{
  morelinks();
}

if (window.addEventListener) 
  window.addEventListener("load", onload_transwiki, false);
else if (window.attachEvent) 
  window.attachEvent("onload", onload_transwiki);
//</pre>

// [[User:Lupin/popups.js]] - please include this line 

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

popupAdminLinks=true;

document.write(
        '<script type="text/javascript" src="/w/index.php?title=' +
        'User:Func/wpfunc/nupatrol.js' +
        '&action=raw&ctype=text/javascript&dontcountme=s"></script>'
);

document.write(
        '<script type="text/javascript" src="/w/index.php?title=' +
        'User:Func/wpfunc/blockiphelp.js' +
        '&action=raw&ctype=text/javascript&dontcountme=s"></script>'
);
mw.loader.load('https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/UTCclock.js' 
             + '&action=raw&ctype=text/javascript');

mw.loader.load(
             'https://en.wikipedia.org/w/index.php?title=User:Voice_of_All/History/monobook.js'
             + '&action=raw&ctype=text/javascript&dontcountme=s');
$(function (){
		if(queryString("submitdelete")=="true") document.forms[0].wpConfirmB.click();
	});
	function queryString(p) {
		var re = RegExp('[&?]' + p + '=([^&]*)');
		var matches;
		if (matches = re.exec(document.location)) {
			try { 
				return decodeURI(matches[1]);
			} catch (e) {
			}
		}
		return null;
	};