Skip to content

Instantly share code, notes, and snippets.

@Ladsgroup Ladsgroup/ores.js
Created Oct 29, 2016

Embed
What would you like to do?
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
You can’t perform that action at this time.