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.
// <nowiki>
// 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;
}

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.
  add_link("/w/wiki.phtml?title=Special:Newpages&limit=500&offset=0", 'New Pages'); 
}

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]]

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