Jump to content

User:Func/monobook.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Func (talk | contribs) at 19:02, 14 September 2005 (temporary testing of new standalone functionality for Newusers log). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
function NUPatrol()
{
	if ( window.location.href.indexOf( 'Special%3ALog&type=newusers' ) != -1 ) // make more robust???
	{
		var items, item, i, links, user, name, talk, contribs, insertLoc, link;

		items = document.getElementById( 'bodyContent' ).getElementsByTagName( 'ul' )[ 0 ].getElementsByTagName( 'li' );

		function NewLink( txt, url, plainlinks, linkColor )
		{	var a = document.createElement( 'a' );
				a.appendChild( document.createTextNode( txt ) );
				a.href = url;
			if ( plainlinks ) a.className = 'plainlinks';
			if ( linkColor )
			{	if ( typeof linkColor == "string" )
						a.style.color = linkColor;
				else	a.style.color = '#FF0000'; // old default behavior
			}
			return a;
		}

		for ( i = 0; i < items.length; i++ )
		{
			item = items[ i ];
			
			links = item.getElementsByTagName( 'a' );

			    user = links[ 0 ]; name = user.firstChild.nodeValue;
			    talk = links[ 2 ]; talk.firstChild.nodeValue = 'talk'; // lowercase 'Talk' for consistency
			contribs = links[ 3 ];

			insertLoc = user.nextSibling; // ' newusers '

			item.insertBefore( document.createTextNode( ' ( ' ), insertLoc );

			item.insertBefore( talk, insertLoc );
			item.insertBefore( document.createTextNode( ', ' ), insertLoc );

			item.insertBefore( contribs, insertLoc );
			item.insertBefore( document.createTextNode( ', ' ), insertLoc );

			item.insertBefore( NewLink( 'actions', URL, true ), insertLoc );
			item.insertBefore( document.createTextNode( ', ' ), insertLoc );

			item.insertBefore( NewLink( 'blocks', URL, true, '#00AA00' ), insertLoc );
			item.insertBefore( document.createTextNode( ', ' ), insertLoc );

			item.insertBefore( NewLink( 'is blocked?', URL, true, '#AAAA00' ), insertLoc );
			item.insertBefore( document.createTextNode( ', ' ), insertLoc );

			item.insertBefore( NewLink( 'do block!', URL, true, '#AA0000' ), insertLoc );

			item.insertBefore( document.createTextNode( ' )' ), insertLoc );

			item.removeChild( insertLoc.nextSibling ); // should remove the span
			item.removeChild( insertLoc ); // should remove ' newusers ' text
		}
	}
}
if ( window.addEventListener ) window.addEventListener( 'load', NUPatrol, false );
else if ( window.attachEvent ) window.attachEvent( 'onload', NUPatrol );