User:Sneltrekker/monobook.js

/* */ ////////////////////////////////////////// // Bits and pieces copied from User:Adam1213/monobook.js // By Sneltrekker // Some changes made, removed all admin buttons //////////////////////////////////////////

document.write('<\/SCRIPT>');

// 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'); popupDelay = 0.1;

// Modified to use test-n, test2-n and test3-n. Remember to put the article title in the tag. ////////////////////////////////////////// // Tabs by Korath // returns  name ///////////////////////////////////////// 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 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 += "" + page + " ~" + "~" + "~" + "~"; if (t.value > 2) f.wpSummary.value = "Vandalism to " + page + " - warning " + number; else f.wpSummary.value = "Regarding " + 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 += "" + page + " ~" + "~" + "~" + "~"; f.wpSummary.value = "regarding " + page + ""; }

function bvn(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 += "" + page + " ~" + "~" + "~" + "~"; f.wpSummary.value = "comment on " + 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) {     tabs.appendChild(addlilink('javascript:edit_summary_watch(" ~" + "~" + "~" + "~", "", false, 0)',"Anon")); tabs.appendChild(addlilink('javascript:edit_summary_watch(" ~" + "~" + "~" + "~", "Welcome!", false, 0)',"Welcome!")); tabs.appendChild(addlilink('javascript:testn(1)',"t1")); tabs.appendChild(addlilink('javascript:testn(2)',"t2")); tabs.appendChild(addlilink('javascript:blankwarn(2)',"t2a")); tabs.appendChild(addlilink('javascript:testn(3)',"t3")); tabs.appendChild(addlilink('javascript:bvn(1)',"bv-n")); } }

if (window.addEventListener) window.addEventListener("load", add_tabs, false); else if (window.attachEvent) window.attachEvent("onload", add_tabs);

if ( document.createElement && window.addEventListener ) {	function SoFixItInit // pre-load, (don't want to slow down loading of article's content, though) {

}

function SoFixItLoad // post-load {		UserMenu = new PortletMenu( 'p-personal'  ); PageMenu = new PortletMenu( 'p-cactions'  ); NavMenu = new PortletMenu( 'p-navigation' ); //ToolMenu = new PortletMenu( 'p-tb'        );

//	This is inefficient and not particularly robust. //	This comes first, I want this link to come up as //	fast as possible. //		function GetByClass( sElem, sClass ) {	var i, a2 = [], a = document.getElementsByTagName( sElem ); for ( i = 0; i < a.length; i++ ) if ( a[ i ].className == sClass ) a2.push( a[ i ] ); return a2; }		var a, td = GetByClass( 'td', 'diff-otitle' ); if ( ( td = td[ 0 ] ) && ( a = td.getElementsByTagName( 'a' )[ 0 ] ) ) a.href = a.href + '&action=edit'; // need to change text, later

var userName = UserMenu.getText( 'pt-userpage' ); UserMenu.setText( 'pt-mytalk'   , 'My Talk'  ); UserMenu.setText( 'pt-preferences', 'Prefs' ); UserMenu.setText( 'pt-watchlist', 'Watchlist' ); UserMenu.setText( 'pt-mycontris', 'Contribs' ); UserMenu.setText( 'pt-logout'   , 'Log out'   ); //		UserMenu.setHref( 'pt-mycontris','http://en.wikipedia.org/w/index.php?title=Special:Contributions&target=' + userName + '&offset=0&limit=500' ); //			//			//	it seems there is a stylesheet that makes them lowercase //			//		ok, the lowercased menu items are starting to really bug me: //		document.getElementById( 'p-personal' ).getElementsByTagName( 'ul' )[0].style.textTransform = 'none'; UserMenu.insertBefore( 'pt-logout' , 'pt-logs', 'Logs','/w/index.php?title=Special%3ALog&user=' + userName ); UserMenu.insertBefore( 'pt-irc' , 'pt-vandal' , 'VAN', 'irc://irc.freenode.net/wikipedia-en-vandalism' ); UserMenu.insertBefore( 'pt-logs'   , 'pt-kate', 'Kate',			'javascript:void InlineKate( "' + userName + '" )' ); if(document.getElementById('ca-edit')) document.getElementById('ca-edit').firstChild.innerHTML = 'Edit';

//	so I always know what time it is in UTC land: //		UserMenu.append( 'pt-utc', UTCTime, 'javascript:void UserMenu.setText("pt-utc",UTCTime)' );

var x = 1; NavMenu.append( 'n-' + x++, 'monobook.js', '/wiki/User:' + userName + '/monobook.js' ); NavMenu.append( 'n-' + x++, 'Vandalism Fighter', 'http://www.csclub.uwaterloo.ca/~dawill03/cdvf/vf.jar' ); }

function PortletMenu( id ) // constructor {		this.menu = document.getElementById( id ); this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass " Views ", etc.

//	sigh...as far as I can figure, there is empty whitespace being treated //	as TextNodes.... //		var LIs = this.list.getElementsByTagName( 'li' );

for ( var i = 0; i < LIs.length; i++ ) {			this[ LIs[ i ].id ] = LIs[ i ]; }

this.newItem = function( id, txt, url ) {	var li = document.createElement( 'li' ); li.id  = id; var a = document.createElement( 'a'  );  a.href = url;

a.appendChild( document.createTextNode( txt ) ); li.appendChild( a );

this[ id ] = li; // watch this!!!

return li; }

this.append = function( id, txt, url ) {	this.list.appendChild( this.newItem( id, txt, url ) ); }		this.insertBefore = function( old, id, txt, url ) {	this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] ); }

//	the ByTagName here is a bit annoying, but in Safari, I was picking //	up TextNodes by using this[ id ].firstChild.firstChild //		this.getText = function( id     ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data } this.setText = function( id, txt ) {       this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }

this.getHref = function( id     ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href       } this.setHref = function( id, url ) {       this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url } //	I add em as I need em.... }

function InlineKate( user ) {		var kate = 'http://tools.wikimedia.de/~kate/cgi-bin/count_edits?dbname=enwiki&user=' + user;

var div = document.createElement( 'div' ); div.id = 'inlineKateDiv'; div.style.position = 'absolute'; div.style.zIndex  = 1000; div.style.left    =  '20px'; div.style.top     =  '20px'; div.style.backgroundColor = '#FFFFFF'; div.style.borderStyle    = 'solid'; div.style.borderWidth    = ' medium'; div.style.borderColor    = '#000000';

var top = document.createElement( 'div' ); top.id = 'inlineKateTop'; top.style.textAlign = 'right'; top.style.margin = '8px'; top.style.backgroundColor = '#DDDDDD';

var a = document.createElement( 'a' ); a.appendChild( document.createTextNode( "Go to Kate's" ) ); a.href   = kate; a.target = '_parent'; a.style.margin = '8px';

top.appendChild( a );

a = document.createElement( 'a' ); a.appendChild( document.createTextNode( 'Close' ) ); a.href   = "javascript:void RemoveNode('inlineKateDiv')"; a.style.margin = '8px';

top.appendChild( a );

div.appendChild( top );

var iframe = document.createElement( 'iframe' ); iframe.id  = 'inlineKateBot'; iframe.style.width = '300px'; iframe.style.height = '400px'; iframe.style.margin =  '8px'; iframe.style.borderStyle = 'solid'; iframe.style.borderWidth = 'thin'; iframe.style.borderColor = '#000000'; iframe.src = kate;

div.appendChild( iframe );

document.body.appendChild( div ); }

function RemoveNode( id ) {	var node = document.getElementById( id ) node.parentNode.removeChild( node ); }

function UTCTime {			//	Get a date stamp for the time in UTC-land. //			//	for the future: a format arg //		var s = '', d = new Date, a = 'Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec'.split(' '); return	d.getUTCDate + ' ' + a[ d.getUTCMonth ] + ' ' + d.getUTCFullYear + ' ' + ( '0' + d.getUTCHours  ).substr( -2 ) + ':' + ( '0' + d.getUTCMinutes ).substr( -2 ) + ' ' + 'UTC'; }

SoFixItInit; window.addEventListener( 'load', SoFixItLoad, false ); }

//