User:Belteshazzar/monobook.js

function getNumFromString (i,eltsByTag) { var resultString, string = eltsByTag.item(i).innerHTML, separator = /[^0-9]/g, regString = { 'en' : /\((.*) bytes?\)/, 'fr' : /\((.*) octets?\)/ },       empty = { 'en' : '(empty)', 'fr' : '(vide)', 'pt' : '(vazia)', 'pt-br' : '(vazio)' }; if( string == ( empty[ mw.config.get( 'wgUserLanguage' ) ] || empty.en ) ) { string=0; } else { resultString= ( regString[ mw.config.get( 'wgUserLanguage' ) ] || regString.en ).exec(string); string = resultString[1].replace(separator,""); string = parseInt(string, 10); } return string; } function makeNumDiff { var  string, resultPrevString = 0, // précédent dans l'ordre chronologique resultNextString = 0, className, lastI = 0, i = 0, eltsByTag = document.getElementsByTagName("span"), length = eltsByTag.length; while(i0) { className = "mw-plusminus-pos"; string = "+" + string; }       else { if (string<0) { className = "mw-plusminus-neg"; } else { className = "mw-plusminus-null"; }       }        if (string<-500 || string>500) { string = " " + "(" + string + ")" + " "; } else { string = "(" + string + ")"; }       eltsByTag.item(lastI).innerHTML = string ; eltsByTag.item(lastI).className = className; resultNextString = resultPrevString; lastI = i;     } i++; } } } if(mw.config.get( 'wgAction' ) && mw.config.get( 'wgAction' ) == "history") { $(makeNumDiff); }