User:Xaradnam/w.js

// $( function {	if( QueryString.exists( 'diff' ) ) {		var oXPath = '//div[@id="mw-diff-otitle2"]/span[@class="mw-usertoollinks"]/a[1]';		var nXPath = '//div[@id="mw-diff-ntitle2"]/span[@class="mw-usertoollinks"]/a[1]';		var oList = document.evaluate( oXPath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );		var nList = document.evaluate( nXPath, document, null,  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null );

if( oList.snapshotLength > 0 || nList.snapshotLength > 0 ) { var spanTag = function( color, content ) { var span = document.createElement( 'span' ); span.style.color = color; span.appendChild( document.createTextNode( content ) ); return span; }

var welcomeNode = document.createElement('strong'); var welcomeLink = document.createElement('a'); welcomeLink.appendChild( spanTag( 'Black', '[' ) ); welcomeLink.appendChild( spanTag( 'Goldenrod', 'w' ) ); welcomeLink.appendChild( spanTag( 'Black', ']' ) ); welcomeNode.appendChild(welcomeLink);

if( oList.snapshotLength > 0 ) { var oTalkNode = oList.snapshotItem(0);

var oHref = document.evaluate( '@href', oTalkNode, null, XPathResult.STRING_TYPE, null ).stringValue;

var oWelcomeNode = welcomeNode.cloneNode( true ); oWelcomeNode.firstChild.setAttribute( 'href', oHref + '?w=1&' + QueryString.create( { 'vanarticle': wgPageName.replace(/_/g, ' ') } ) ); oTalkNode.parentNode.parentNode.appendChild( document.createTextNode( ' ' ) ); oTalkNode.parentNode.parentNode.appendChild( oWelcomeNode ); }

if( nList.snapshotLength > 0 ) { var nTalkNode = nList.snapshotItem(0);

var nHref = document.evaluate( '@href', nTalkNode, null, XPathResult.STRING_TYPE, null ).stringValue;

var nWelcomeNode = welcomeNode.cloneNode( true ); nWelcomeNode.firstChild.setAttribute( 'href', nHref + '?w=1&' + QueryString.create( { 'vanarticle': wgPageName.replace(/_/g, ' ') } ) ); nTalkNode.parentNode.parentNode.appendChild( document.createTextNode( ' ' ) ); nTalkNode.parentNode.parentNode.appendChild( nWelcomeNode ); }		}	} } ); //