User:DannyS712/Pretty rights log.js

// Install with: // // or with //  // // If forking this script, please note my contributions / give me credit // $(function { mw.loader.using( 'mediawiki.util', function { $(document).ready( function {     	if ( mw.config.get('wgCanonicalNamespace') === 'Special' && (mw.config.get('wgCanonicalSpecialPageName') === 'Log' || mw.config.get('wgCanonicalSpecialPageName') === 'Userrights') ){    		$('[data-mw-logaction="rights/rights"]').each( function { this.innerHTML = this.innerHTML.replace( /(changed group membership for .*?<\/a>) (.*?)( |\s+\(<a class="mw-thanks-thank-link")/, replacer );			}); }   } ); } ); function replacer( match, p1, p2, p3, offset, string ){ console.log( p2 ); var np2 = filter( p2 ); return( p1 + ': ' + np2 + p3 ); } function filter( p2 ){ var split = p2.split( " to " ); from = split[0].replace( /^from /, '' ).replace( /, (until|\d)/g, ',_$1' ).replace( / and /, ', '); to = split[1].replace( /, (until|\d)/g, ',_$1' ).replace( / and /, ', '); var fromA = from.split( ', ' ); var toA = to.split( ', ' ); var fromAF = []; var toAF = []; for ( var iii = 0; iii < fromA.length; iii++ ){ if ( toA.indexOf( fromA[iii] ) === -1 ){ fromAF.push( fromA[iii] ); }	}	for ( var jjj = 0; jjj < toA.length; jjj++ ){ if ( fromA.indexOf( toA[jjj] ) === -1 ){ toAF.push( toA[jjj] ); }	}	var removed = fromAF.join( ', ' ); if ( removed === '' ){ removed = '(none)'; }	var added = toAF.join( ', ' ); if ( added === '' ){ added = '(none)'; }	var change = 'removed ' + removed + ', added ' + added; change = change.replace( /_/g, ' ' ); console.log( split, from, to, fromA, toA, fromAF, toAF, removed, added, change ); return change; } }); //