Created
October 29, 2016 20:31
-
-
Save Ladsgroup/e67e40500b64dd99dc7ab5c2fa34f261 to your computer and use it in GitHub Desktop.
A simple ScoredRevision alternate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MIT license | |
// Author: Amir Sarabadani <[email protected]> | |
mw.config.set( 'ORESHighlighter', { | |
0.075: '#ffe099', | |
0.37: '#ffbe99', | |
0.90: '#f4908a' | |
}); | |
( function ( mw, $ ) { | |
'use strict'; | |
if ( !$('.mw-changeslist').length && !$('mw-contributions-list').length ) { | |
return; | |
} | |
var colors = mw.config.get( 'ORESHighlighter' ); | |
$('li').each( function (){ | |
if ( $( this ).children('a').attr('href') ) { | |
var reg = /diff=(\d+)/ig; | |
var res = reg.exec( $(this).children('a').attr('href') ); | |
if (res && res[1] in mw.config.get('oresData')) { | |
var score = mw.config.get('oresData')[res[1]]['damaging']; | |
var threshold = 0; | |
for ( threshold in colors ) { | |
if ( score > threshold ) { | |
$( this ).css( 'background-color', colors[threshold]); | |
} | |
} | |
} | |
} | |
} ) | |
}( mediaWiki, jQuery ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment