User:Kelly Martin/monobook.js

From Wikipedia, the free encyclopedia

If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
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.
// Nerf!
// [[User:Lupin/popups.js]] - please include this line 
 
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
popupDelay = 1;
popupAdminLinks = false;
popupFixRedirs = true;
popupFixDabs = true;
 
/* <pre><nowiki> */
//////////////////////////////////
// [[User:Essjay]]'s monobook.  //
//////////////////////////////////
 
// Please note: There are sysop, bureaucrat, and checkuser function settings in this skin.  //
//              They appear under tabs with the associated names (syop, bcrat, check).      //
//              They will not work if you do not have the required permissions.             // 
//              Do not be alarmed if you get error messages.                                //
//              (They can easily be removed, ask me.)                                       //
 
 
/**** Initialize on window load ****/
 
addOnloadHook( myLoadFuncs );
 
/**** Load custom functions ****/
 
function myLoadFuncs()
{
    if(!document.getElementById) return;
    // add a clock
    var toplinks = document.getElementById('p-personal').getElementsByTagName('ul')[0];
    addlilink(toplinks, '#', '', 'utcdate');
    showtime();
    morelinks();
}
 
/**** Add generic tab ****/
 
function addlilink(tabs, url, name, id){
    var na = document.createElement('a');
    na.href = url;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}
 
//////////////////////////////////////////
// Tabs by Korath
// returns <li><a href="url">name</a></li>
//////////////////////////////////////////
/**** Add tab as menu ****/
 
function addlimenu(tabs, name, id)
{
    var na = document.createElement('a');
    na.href = '#';
    var mn = document.createElement('ul');
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.id = id;
    li.className = 'tabmenu';
    li.appendChild(na);
    li.appendChild(mn);
    tabs.appendChild(li);
    return li;
}
 
/**** Get a clock that autoupdates! ****/
 
function showtime()
{
    var timerID;
    var now = new Date();
    var timeValue = now.toUTCString().replace(/GMT/, "UTC");
    document.getElementById('utcdate').firstChild.innerHTML = timeValue;
    timerID = setTimeout('showtime()', 100);
}
 
function addTab(url, name, id, title, key){ 
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
    addlilink(tabs, url, name, id, title, key);
}
 
// 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 = document.getElementById('p-cactions').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
    addTab('/wiki/Special:Blockip/' + editlk, 'block', 'ca-block');
 
    // add "blocklog" tab
    addTab('/wiki/Special:Log/block?page=User:' + editlk, 'log', 'ca-blocklog');
 
    // add "unblock" tab
    addTab('/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'un');
 
    // add "contributions" tab
    addTab('/wiki/Special:Contributions/' + editlk, 'con');
 
    // add "edit count" tab
    addTab('http://tools.wikimedia.de/~interiot/cgi-bin/count_edits?user=' + editlk + '&dbname=enwiki_p', 'count');
 
    // add "whois" tab
    addTab('http://tools.wikimedia.de/~essjay/nqt.php?queryType=arin&target=' + editlk, 'who');
 
    // add "proxycheck" tab
    addTab('http://quyme.com/proxycheck.php?ip=' + editlk, 'proxy');
}
function morelinks()
{
    var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];
if(document.title.indexOf("User") == 0)
    {
        addlimenu(tabs, 'User', 'userf');
        var userf = document.getElementById('userf').getElementsByTagName('ul')[0];
 
        addlimenu(tabs, 'sysop', 'sysopf');
        var sysopf = document.getElementById('sysopf').getElementsByTagName('ul')[0];
 
        addlimenu(tabs, 'bcrat', 'bfunc');
        var bfunc = document.getElementById('bfunc').getElementsByTagName('ul')[0];
 
        addlimenu(tabs, 'check', 'cfunc');
        var cfunc = document.getElementById('cfunc').getElementsByTagName('ul')[0];
 
 
             //User functions //
 
        var editlk = document.getElementById('ca-edit').getElementsByTagName('a')[0].href;
            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);
 
        // format: addlilink(userf, url, name);
 
        // add "listusers" tab
        addlilink(userf, '/w/index.php?title=Special:Listusers&group=&username=' + editlk, 'list', '');
 
        // add "contributions" tab
        addlilink(userf, '/wiki/Special:Contributions/' + editlk, 'contrib', '');
        // addTab('/wiki/Special:Contributions/' + editlk, 'con');
 
        // add "userspace" tab
        addlilink(userf, '/w/index.php?title=Special:Prefixindex&namespace=2&from=' + editlk, 'space', '');
 
        // add "edit count" tab
        addlilink(userf, 'http://tools.wikimedia.de/~essjay/edit_count/Count.php?username=' + editlk, 'count', '');
        // addTab('http://tools.wikimedia.de/~essjay/edit_count/Count.php?username=' + editlk, 'count');
 
        // add "whois" tab
        addlilink(userf, 'http://tools.wikimedia.de/~essjay/nqt.php?queryType=arin&target=' + editlk, 'whois', '');
        // addTab('http://tools.wikimedia.de/~essjay/nqt.php?queryType=arin&target=' + editlk, 'who');
 
        // add "proxycheck" tab
        addlilink(userf, 'http://quyme.com/proxycheck.php?ip=' + editlk, 'proxy', '');
        // addTab('http://quyme.com/proxycheck.php?ip=' + editlk, 'proxy');
 
        // add "url" tab
        addlilink(userf, 'http://' + editlk, 'url', '');
        // addTab('http://' + editlk, 'url');
 
 
                // Sysop functions
 
        // add "block" tab
        addlilink(sysopf, '/wiki/Special:Blockip/' + editlk, 'block');
        // previous: addTab('/wiki/Special:Blockip/' + editlk, 'block', 'ca-block', '');
 
        // add "blocklog" tab
        addlilink(sysopf, '/wiki/Special:Log/block?page=User:' + editlk, 'log', '');
        // addTab('/wiki/Special:Log/block?page=User:' + editlk, 'log', 'ca-blocklog');
 
        // add "unblock" tab
        addlilink(sysopf, '/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'unblock', '');
        // addTab('/w/index.php?title=Special:Ipblocklist&action=unblock&ip=' + editlk, 'un');
 
        // add "view deleted edits" tab
        addlilink(sysopf, 'http://tools.wikimedia.de/~interiot/cgi-bin/queries/tmp/del?user=' + editlk + '&dbname=enwiki', 'deleted', '');
 
 
                //Checkuser functions
 
        // add "checkuser" tab
        addlilink(cfunc, 'http://en.wikipedia.org/w/index.php?title=Special:CheckUser&user=' + editlk, 'user', '');
 
        // add "checkip" tab
        addlilink(cfunc, 'http://en.wikipedia.org/w/index.php?title=Special:CheckUser&ip=' + editlk, 'ip', '');
 
        // add "log" tab
        addlilink(cfunc, 'http://en.wikipedia.org/w/index.php?title=Special:CheckUser&log=1', 'log', '');
 
 
    }
}
 
function do_onload()
{
 if (document.title.indexOf('Block user') == 0) // could stand to be more robust
    do_blockip_stuff();
}
 
//From User:Func
if (window.addEventListener) 
  window.addEventListener("load", do_onload, false);
else if (window.attachEvent) 
  window.attachEvent("onload", do_onload);
 
 
 
/*
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:Topaz/init.js");
inc("User:Topaz/util.js");
inc("User:Topaz/comm.js");
inc("User:Topaz/wputil.js");
*/
 
//Interiot's Java //
 
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>');
 
// Unwatch Links //
 
addOnloadHook(function () {
    var query_prefix = "title=Special:Watchlist&action=submit&remove=1&id[]=";
    //var query_prefix = "action=unwatch&title=";
 
    if (window.location.href.indexOf("Special:Watchlist") < 0) return;
    if (window.location.href.indexOf("Special:Watchlist/edit") >= 0) return;
 
    var links = document.getElementById('content').getElementsByTagName('a');
    for (var i = 0; i < links.length; i++) {
        if (links[i].href.substring(links[i].href.length-15) != '&action=history')
            continue;
        var unwatch = document.createElement('a');
        unwatch.href = "/w/index.php?" + query_prefix + encodeURIComponent(links[i].title);
        unwatch.title = "Unwatch "+links[i].title;
        unwatch.appendChild(document.createTextNode("unwatch"));
        links[i].parentNode.insertBefore(unwatch, links[i].nextSibling);
        // kluge to handle case where "diff" is unlinked:
        var delim = links[i].previousSibling;
        delim = (delim.nodeType == 3 ? delim.nodeValue : "");
        links[i].parentNode.insertBefore(document.createTextNode(delim.replace(/^.*diff/, "")), unwatch);
    }
});
 
//Death to editing on redlinks //
 
function stopRedlinksEditing(){ 
    var len=document.links.length;
    for(var i=0; i<len; ++i) {
        var l=document.links[i];
        if (l.className=='new') {
            l.href=l.href.replace('&action=edit', '');
        }
    }
}
addOnloadHook(stopRedlinksEditing); 
 
//BCrats stuff//
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Essjay/bureaucrat.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//Checkuser reporting//
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Essjay/checkuser.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
//Rename results//
document.write('<script type="text/javascript" src="' 
             + 'http://en.wikipedia.org/w/index.php?title=User:Essjay/rename.js' 
             + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
/*
//Autodelete with Jude's delete tool//
 
addOnloadHook(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;
	};
 
*/
 
// Always check "block anons only" on Special:Blockip //
// Another success from User:Lupin // 
 
addOnloadHook(function(){ var x; if (x=document.getElementById('wpAnonOnly')) {x.checked=true;} });
addOnloadHook(function(){ var x; if (x=document.getElementById('wpCreateAccount')) {x.checked=false;} });
 
 
// </nowiki></pre> //
 
//On diff pages this script replaces ''(Difference between revisions)''with
//different tools for reverting the edit and warning the user that made the edit.
//For instructions see talk page.
// Revert tools by Lorian
function getElementsByClass(searchClass,node,tag) {
  // Function from http://www.dustindiaz.com/getelementsbyclass/
  var classElements = new Array();
  if ( node == null )
    node = document;
  if ( tag == null )
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  for (i = 0, j = 0; i < elsLen; i++) {
    if ( pattern.test(els[i].className) ) {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}
 
// _GET code from NoGray JS Library http://www.nogray.com/new_site/
var _GET = new Array();
var _uri = location.href;
 
var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&");
 
var _temp_get_arr_1 = new Array();
 
for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){
  _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("=");
  _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]);
}
 
delete _uri; delete _temp_get_arr; delete _temp_get_arr_1;
 
function getMessage (where, user1, user2) {
  var message = prompt ('What message would you like to leave?', '');
  window.location = 'http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message;
}
 
addOnloadHook(function (){
  if (location.href.match(/diff=/)) {
    // Get username of submitter
    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;
    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;
    document.getElementById('contentSub').innerHTML = '(<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&revert=1&user1='+user1+'&user2='+user2+'">Revert</a> / <a href="javascript:var message = getMessage(\'revert\', \''+user1+'\', \''+user2+'\');">Message</a>) (<a href="http://en.wikipedia.org/w/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&vandalism=1&user1='+user1+'&user2='+user2+'">Vandalism</a> / <a href="javascript:var message = getMessage(\'vandalism\', \''+user1+'\', \''+user2+'\');">Message</a>) (Warn: <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=1">Test</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=2">Blatant</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=3">Nonsense</a> / <a href="http://en.wikipedia.org/w/index.php?title=User_talk:'+user2+'&action=edit&section=new&warn=4">Blanking</a>)';
  } else if (location.href.match(/revert=1/)) {
    document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/revert=2/)) {
    document.getElementById('wpSummary').value = 'Reverted edits by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=1/)) {
    document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']]';
    document.getElementById('editform').submit();
  } else if (location.href.match(/vandalism=2/)) {
    document.getElementById('wpSummary').value = 'Reverted vandalism by [[Special:Contributions/'+_GET['user2']+'|'+_GET['user2']+']] to version ' + _GET['oldid']+' by [[Special:Contributions/'+_GET['user1']+'|'+_GET['user1']+']] ('+_GET['message']+')';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=1/)) {
    document.getElementById('wpSummary').value = 'Vandalism warning';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:test}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=2/)) {
    document.getElementById('wpSummary').value = 'Vandalism warning';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:blatantvandal}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=3/)) {
    document.getElementById('wpSummary').value = 'Vandalism warning';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:test2}} ~~'+'~~';
    document.getElementById('editform').submit();
  } else if (location.href.match(/warn=4/)) {
    document.getElementById('wpSummary').value = 'Vandalism warning';
    document.getElementById('wpTextbox1').value = '{{sub'+'st:test2a}} ~~'+'~~';
    document.getElementById('editform').submit();
  }
});