// ==UserScript==
// @name RS-Online total cost highlighter
// @namespace http://tampermonkey.net/
// @version 0.1-190423
// @description RS-Online (CZ) total cost calculator-highlighter
// @author Shaddack
// @match https://*.rs-online.com/web/c/*
// @grant none
// ==/UserScript==
// usage:
// press '/' to highlight prices (0=white, pricemax=colmin dark gray)
// press '?' to also hide rows with big packs, more than maxcount items - rarely we need an entire reel
(function() {
'use strict';
document.onkeypress=function(ev){
var pricemax=1000; // max price for the range, allabove that is colmin shade
var colmin=0x44; // price no darker than this
var maxcount=1000; // parts count above which we hide the rows
var maxcountcol="#555555";
var c,cc,o,oo,n,a,aa,aaa,t,tt,count,price,pricetot,s,s1,s2,col,colstr,reformatted;
// alert('ev='+ev+':'+ev.target.nodeName+':'+ev.target.getAttribute('type'));
if (ev.target.nodeName.toLowerCase() == 'input')return true;
if (ev.target.nodeName.toLowerCase() == 'textarea')return true;
if(window.event)c=window.event.keyCode;else if(ev)c=ev.which;
cc=c;
c=String.fromCharCode(c);
// alert('KEY:'+c+':'+cc);
if(c==','){alert('KEY:'+c+':'+cc);return false;} // test
if((c=='/')||(c=='?')){
// the meat goes here
a=document.getElementsByClassName('resultRow');if(!a){alert("no classname found!");return false;}
for(t=1;t"+aa[0].innerHTML+"";
//
if(pricetot>pricemax)col=colmin;else{
col=((pricemax-pricetot)/pricemax)*(255-colmin)+colmin;
if(col>255)col=255;else if(col<0)col=0;else col=Math.round(col);
}
//
if(count>=maxcount){
a[t].style.backgroundColor=maxcountcol;
a[t].style.size="80%";
//a[t].style.height="20px";
//a[t].style.overflow="hidden";
if(c=='?'){ // hide big boxes of stuff
a[t].style.visible="hidden";
a[t].style.display="none";
}
//
}
//
colstr='rgb('+col+','+col+','+col+')';
aa=a[t].getElementsByClassName('priceCol');
aa[0].style.backgroundColor=colstr;
//a[t].style.backgroundColor=colstr;
//if(pricetot>1000){a[t].style.backgroundColor=colstr;continue;}
}
}
}
})();