User:Cat-five/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.
// <pre><nowiki>
 
//Add LI Link
 
function addlilink(tabs, url, name, id, title, key){
    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);
    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;
}
 
 
//
//
// Break between scripts
//
//
 
//Add Tab Script
 
function addTab(url, name, id, title, key){
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}
 
 
//
//
// Break between scripts
//
//
 
//Block and Blocklog tab scripts
 
// 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;
}
 
// Adds a "blocklog" tab and fills in the username field on Special:Blockip, if a "&faketarget=username" is present.
function do_blockip_stuff()
{
  // focus on Reason field
  document.getElementsByName('wpBlockReason')[0].focus();
 
  // Look for a &faketarget= for the username/ip
  var l = location.search.substring(1).split('&');
  var target = '';
  for (var i = 0; i < l.length; ++i)
    {
      var n = l[i].indexOf('=');
      if (l[i].substring(0, n) == 'faketarget')
	{
	  target = l[i].substring(n + 1);
	  break;
	}
    }
 
  if (target == '')
    return;
 
  // put account name in "IP Address/username" field
  var addr = document.getElementsByName('wpBlockAddress')[0];
  addr.value = unescape(target);
 
  // add "blocklog" tab
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
  tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target, 'blocklog'));
}
 
// Opens the block log in the current window, and Special:Blockip in a popup.
// Width, height, top, and left are chosen for a 1600x1200 display.
//function blockpage_and_log(target)
//{
//  window.open('Special_Blockip.html?foo=blarg&faketarget=' + target, 'Block', 'width=1600,height=600,top=600,left=0');
//  document.location.href = 'http://en.wikipedia.org/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + target;
//}
 
// Adds "block" and "blocklog" tabs to User: and User talk: pages.
function add_block_tab()
{
  var c1 = document.getElementById('column-one');
  var tabs = c1.getElementsByTagName('div')[0].getElementsByTagName('ul')[0];
 
  // use the "edit this page" tab to get already-tidied url
  var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
  // cut everything up to "title=" from the start and everything past "&action=edit" from the end
  editlk = editlk.substring(editlk.indexOf('title=') + 6, editlk.lastIndexOf('&action=edit'));
  editlk = editlk.substring(editlk.indexOf(':') + 1);
  var slloc = editlk.indexOf('/');
  if (slloc > 0)
    editlk = editlk.substring(0, slloc);
 
  // add "block" tab
  tabs.appendChild(addlilink('/w/index.php?title=Special%3ABlockip&faketarget=' + editlk, 'block'));
 
  // To open the block page and block log simultaneously, replace the above line with:
  // tabs.appendChild(addlilink('javascript:blockpage_and_log("' + editlk + '")', 'Block'));
  // and uncomment the blockpage_and_log() function above.
 
  // add "blocklog" tab
  tabs.appendChild(addlilink('/w/index.php?title=Special%3ALog&type=block&user=&page=User%3A' + editlk, 'blocklog'));
}
 
function do_onload()
{
  if (document.title.indexOf('User:') == 0
      || document.title.indexOf('User talk:') == 0)
    add_block_tab();
  else if (document.title.indexOf('Block user') == 0) // could stand to be more robust
    do_blockip_stuff();
}
 
if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);
 
//
//
// Break between scripts
//
//
 
//Auto AFD script
 
//Please include the two following lines
//Modified version of AutoVFD script to work with AFD
 
 
// 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 afd()
{
  document.editform.wpTextbox1.value = '{{' + 'subst:afd}}\n' + document.editform.wpTextbox1.value;
  document.editform.wpSummary.value = 'afd';
 
  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:Articles_for_deletion/' + pagename + '&action=edit&fakeaction=afdsub&faketarget=' + target,
              'Afd ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
  window.open('/w/index.php?title=Wikipedia:Articles_for_deletion/Log/' + date + '&action=edit&fakeaction=afdlist&faketarget=' + pagename,
              'AfdLog ' + unescape(target),
              'status,toolbar,location,menubar,directories,resizeable,scrollbars');
}
 
function autoafd()
{
  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 == 'afdlist')
        {
          document.editform.wpTextbox1.value += '{{' + 'Wikipedia:Articles for deletion/' + target + '}}\n';
          document.editform.wpSummary.value = '[[Wikipedia:Articles for deletion/' + target + ']]';
        }
      else if (action == 'afdsub')
        {
          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 afd at the default location already.\n\n" +
                           'Please either move it out of the way (and update existing links to it), or file the Afd 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:afd()', 'Afd');
    }
}
 
if (window.addEventListener) 
  window.addEventListener('load', autoafd, false);
else if (window.attachEvent) 
  window.attachEvent('onload', autoafd);
 
//
//
// Break between scripts
//
//
 
//Interiot's tool link script
 
  //  Add a "Interiot" link to your monobook "personal menu" list at the very
   //  top of the page.
   //
   //  Indicate where you would like "Interiot" to appear:
   //    pt-userpage, pt-mytalk, pt-preferences,
   //    pt-watchlist, pt-mycontris, pt-logout
   //
 gsInteriotInsertBefore = 'pt-logout'; // leave blank to append after "logout"
   //
 function InteriotLink()
 {
   var user = document.getElementById( 'pt-userpage').firstChild.firstChild.data;
 
   var li = document.createElement( 'li' );
     li.id = 'pt-interiot';
 
     var a = document.createElement( 'a' );
       a.appendChild( document.createTextNode( 'Interiot' ) ); // eh, the css makes the text lowercase
       a.href = 'http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=' + user;
 
     li.appendChild( a );
 
   if ( ! gsInteriotInsertBefore ) // append to end (right) of list
   {  document.getElementById( 'pt-logout' ).parentNode.appendChild( li );
   }
   else
   {  var before = document.getElementById( gsInteriotInsertBefore )
       before.parentNode.appendChild( li, before );
   }
 }
    if ( window.addEventListener ) window.addEventListener( 'load', InteriotLink, false );
 else if ( window.attachEvent      ) window.attachEvent   ( 'onload', InteriotLink );
 
//
//
// Break between scripts
//
//
 
//Force summary script
 
function perhapsSave(ev)
{
   //dump("perhapsSave(ev)\n");
   var sum = document.getElementsByName('wpSummary');
   var submit = true;
   if (sum.length > 0) {
      sum = sum[0];
      if (sum.value == '') {
         if (!document.getElementById('jn-fillIn')) {
            var div = document.createElement('p');
            div.appendChild(document.createTextNode('Fill in the summary!'));
            div.setAttribute('style', 'color: #f00; font-size: 150%;');
            div.id = 'jn-fillIn';
            sum.parentNode.insertBefore(div, sum.nextSibling);
         }
         sum.focus();
         submit = false;
      }
   }
   if (submit) {
      var btn = document.getElementById('wpSave');
      btn.onclick = null;
      btn.setAttribute('type', 'submit');
      btn.click();
   }
}
 
function modifySaveButton()
{
   //dump("modifySaveButton()\n");
   // action=edit for edit pages, action=submit for previews
   if ((window.location.href.indexOf('&action=edit') != -1)
       || (window.location.href.indexOf('&action=submit') != -1)) {
      //dump("   on edit page\n");
      var btn = document.getElementById('wpSave');
      btn.setAttribute('type', 'button');
      btn.onclick = perhapsSave;
   }
}
 
window.addEventListener('load', modifySaveButton, false);
 
//
//
// Break between scripts
//
//
 
//Purge tab script
 
 
function addPurge(){
    ta['ca-purge'] = ['g', 'Purge the internal cache for this page'];
    var x = document.getElementById('ca-history');
    if(!x) return;
    if(x.children) x = x.children[0].href;
    else x = x.childNodes[0].href;
    addTab(x.replace(/=history/, "=purge"), 'purge', 'ca-purge');
    akeytt();
}
 
if (window.addEventListener) window.addEventListener("load", addPurge, false);
else if (window.attachEvent) window.attachEvent("onload", addPurge);
 
//
//
// break between scripts
//
//
 
// Script from [[User:Lupin/popupsdev.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popupsdev.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
popupAdminLinks=true;
popupShortcutKeys=true;
popupFixRedirs=true;
popupFixDabs=true;
popupRedlinkRemoval=true;
popupRevertSummary='rvv';
popupRevertSummaryPrompt=true;
popupFixRedirsSummary='Redirect fixing';
popupFixDabsSummary='[[Wikipedia:Disambiguation|Disambiguation]] repair';
popupRedlinkSummary='delink redlink to non existent article/page';
popupRedlinkRemoval=true;
popupEditCounterTool='custom';
popupEditCounterUrl='http://en.wikipedia.org/wiki/User:Interiot/Tool2/code.js?username=%s';
 
//
//
// break between scripts
//
//
 
document.write(
        '<script type="text/javascript" src="/w/index.php?title=' +
        'User:Func/wpfunc/blockiphelp.js' +
        '&action=raw&ctype=text/javascript&dontcountme=s"></script>'
);
 
//
//
// Break between scripts
//
//
 
 
// Filter changes live
// [[User:Lupin/recent2.js]] - please include this line
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/recent2.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//
//
// Break between scripts
//
//
 
// [[User:Zocky/PicturePopups.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Zocky/PicturePopups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//
//
// Break between scripts
//
//
 
// [[User:Cryptic/toggleundelete.js]]
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Cryptic/toggleundelete.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//
//
// Break between scripts
//
//
 
function inc (file) {
  var lt = String.fromCharCode(60);
  var gt = String.fromCharCode(62);
  document.writeln(lt+'script type="text/javascript" src="/w/index.php?title='+file+'&amp;action=raw&amp;ctype=text/javascript&amp;dontcountme=s"'+gt+lt+'/script'+gt);
}
 
inc("User:Lightdarkness/aiv.js");
 
//
//
// Break between scripts
//
//
 
document.write('<script type="text/javascript" src="' 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js' 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//
//
// Break between scripts
//
//
 
function EnforceWikiBreak() {
    var currentdate = new Date();
                                   // YYYY, MM, DD, HH, MM, SS
    var enforced_break_end = new Date(2006, 03, 23, 03, 40, 00);
                     // *** IMPORTANT: Subtract 1 from month, i.e. january = 0 ***
 
    if (currentdate > enforced_break_end) {
      // alert ("Welcome back from your enforced wikibreak!");
    } else {
      alert ("Enforced wikibreak until " + enforced_break_end.toLocaleString() + " (currently " + currentdate.toLocaleString() + "). Bye!");
      window.location = "http://en.wikipedia.org/w/index.php?title=Special:Userlogout&returnto=Main_page";
    }
}
 
addOnloadHook(EnforceWikiBreak);
 
//
//
// Break between scripts
//
//
 
//hideOwn
 
addOnloadHook(function () {
  for (var i=0; i<document.links.length; ++i) {
    if (document.links[i].href.indexOf('Special:Watchlist')>0) {
      document.links[i].href+='?hideOwn=1';
      break;
    }
  }
});
 
//
 
//
//
// Break between scripts
//
//
 
// Script includer
function winc(s) {
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=' + s
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
}
 
winc('User:Mathwiz2020/afdcloser.js');                        // AfD closer
 
//
//
// Break between scripts
//
//
 
// </nowiki></pre>