Skip to content

Instantly share code, notes, and snippets.

@Ladsgroup
Created October 29, 2016 20:31
Show Gist options
  • Save Ladsgroup/e67e40500b64dd99dc7ab5c2fa34f261 to your computer and use it in GitHub Desktop.
Save Ladsgroup/e67e40500b64dd99dc7ab5c2fa34f261 to your computer and use it in GitHub Desktop.
A simple ScoredRevision alternate
// MIT license
// Author: Amir Sarabadani <ladsgroup@gmail.com>
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