User:Zenwhat/blanktwinkle.js

function twinkletwodiff { if( wgNamespaceNumber < 0 ) { return; }	var query = { 'title': wgPageName, 'diff': 'cur', 'oldid': 'prev' };	mw.util.addPortletLink( 'p-cactions', mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query ), 'last', 'tw-lastdiff', 'Show most recent diff' ); if( !QueryString.exists( 'diff' ) ) { // Not diff page return; } 	var l = mw.util.addPortletLink( 'p-cactions', "javascript:twinkletwodiff.evaluate(false);", 'since', 'tw-since', 'Show difference between last diff and the revision made by previous user' ); var l = mw.util.addPortletLink( 'p-cactions', "javascript:twinkletwodiff.evaluate(true);", 'since mine', 'tw-sincemine', 'Show difference between last diff and my last revision' ); } $( twinkletwodiff ); twinkletwodiff.evaluate = function twinkletwodiffEvaluate(me) { var ntitle = getElementsByClassName( document.getElementById('bodyContent'), 'td', 'diff-ntitle' )[0]; var user; if( me ) { user = wgUserName; } else { var node = document.getElementById( 'mw-diff-ntitle2' ); if( ! node ) { // nothing to do? return; }		user = document.evaluate( 'a[1]', node, null, XPathResult.STRING_TYPE, null ).stringValue; }	var query = { 'prop': 'revisions', 'action': 'query', 'titles': wgPageName, 'rvlimit': 1, 'rvprop': [ 'ids', 'user' ], 'rvstartid': wgCurRevisionId - 1, // i.e. not the current one 'rvuser': user };	Status.init( document.getElementById('bodyContent') ); var wikipedia_api = new Wikipedia.api( 'Grabbing data of initial contributor', query, twinkletwodiff.callbacks.main ); wikipedia_api.params = { user: user }; wikipedia_api.post; } twinkletwodiff.callbacks = { main: function( self ) { var xmlDoc = self.responseXML; var revid = xmlDoc.evaluate( '//rev/@revid', xmlDoc, null, XPathResult.NUMBER_TYPE, null ).numberValue; if( ! revid ) { self.statelem.error( 'no suitable earlier revision found, or ' + self.params.user + ' is the only contributor. Aborting.' ); return; }		var query = { 'title': wgPageName, 'oldid': revid, 'diff': wgCurRevisionId };		window.location = mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?' + QueryString.create( query );