User:Gary/mark edits after my own.js

/*	MARK EDITS AFTER MY OWN Description: Marks edits on contribution pages where the user's edit is not the most recent on that page. Does not mark pages on your watchlist, since you are already notified of those.

if (typeof(unsafeWindow) != 'undefined') {	var console = unsafeWindow.console; importStylesheet = unsafeWindow.importStylesheet; mw = unsafeWindow.mw; sajax_init_object = unsafeWindow.sajax_init_object; }

function markEditsAfterMyOwn {	if (!mw.config.get('wgPageName').match('Special:Contributions')) return; importStylesheet('User:Gary/highlighted link.css'); if ($('#contentSub').children.eq(0).text == mw.config.get('wgUserName')) var isOwnUserContributions = true; else var isOwnUserContributions = false; // get watchlist items first so that they aren't marked as well, only for current user's contributions if (isOwnUserContributions) $.get(mw.config.get('wgScriptPath') + '/api.php', { action: 'query', list: 'watchlist', wllimit: 500, format: 'json' }, markEditsAfterMyOwnWatchlist); else markEditsAfterMyOwnMark('', false); };

function markEditsAfterMyOwnWatchlist(obj) {	var watchlist = obj['query']['watchlist']; var pagesToIgnore = {}; for (var i = 0; i < watchlist.length; i++) {		if (pagesToIgnore[watchlist[i]['title']]) pagesToIgnore[watchlist[i]['title']]++; else pagesToIgnore[watchlist[i]['title']] = 1; }	markEditsAfterMyOwnMark(pagesToIgnore, true); }

function markEditsAfterMyOwnMark(pagesToIgnore, isOwnUserContributions) {	if (isOwnUserContributions && $.isEmptyObject(pagesToIgnore)) $('#contentSub').append('. Your watchlist is empty. '); if (!pagesToIgnore) pagesToIgnore = {}; var markedPages = {}; $('#bodyContent ul:last').children.each(function	{		var edit = $(this);		if (edit[0].nodeType == 3) return true;		var pageName = edit.children.eq(0).attr('title');		if ($('.mw-uctop', edit).length) markedPages[pageName] = 1;		else		{			if (markedPages[pageName]) markedPages[pageName]++;			else			{				// get the link to highlight it				var nodeNumber;				var children = edit.children;				var normalNode = 3;				var minorNode = 4;				var deletedNode = 2;				// Take the fourth A node. If not available, then always take the second.				var linkToHighlight = $('a:eq(3)', edit);				if (!linkToHighlight.length) linkToHighlight = $('a:eq(1)', edit);				// in most cases				// if (children.eq(normalNode).length && children.eq(normalNode)[0].nodeName == 'A') nodeNumber = normalNode;				// is a minor edit				// else if (children.eq(minorNode).length && children.eq(minorNode)[0].nodeName == 'A') nodeNumber = minorNode; // a deleted edit // else if (children.eq(deletedNode).length && children.eq(deletedNode)[0].nodeName == 'A') nodeNumber = deletedNode;

linkToHighlight.addClass(pagesToIgnore[pageName] ? 'highlighted-link-watched' : 'highlighted-link'); markedPages[pageName] = 1; }		}	}); }

$(markEditsAfterMyOwn);