bookmarklet that calculates Fanduel fantasy point totals for NBA players and sorts by performance for ESPN Box Scores.
javascript:(function(){function e(){var e=document.getElementsByClassName("mod-data")[0].tBodies[0];var t=[];for(var n=0,r=e.rows.length;n<r;n++){var i=e.rows[n];var s=parseFloat(i.cells[1].textContent||i.cells[1].innerText);if(!isNaN(s))t.push([s,i])}t.sort(function(e,t){return t[0]-e[0]});for(var n=0,r=t.length;n<r;n++){e.appendChild(t[n][1])}t=null}function t(e,t){e.classList.remove("odd");e.classList.remove("even");for(var n=0;n<e.cells.length;n++){e.cells[n].classList.add(t)}return e}function n(e,n){if(n>=60){t(e,"fanduel-1")}else if(n>=55){t(e,"fanduel-2")}else if(n>=50){t(e,"fanduel-3")}else if(n>=45){t(e,"fanduel-4")}else if(n>=40){t(e,"fanduel-5")}else if(n>=35){t(e,"fanduel-6")}else if(n>=30){t(e,"fanduel-7")}else if(n>=25){t(e,"fanduel-8")}else if(n>=20){t(e,"fanduel-9")}else if(n>=15){t(e,"fanduel-10")}else{t(e,"fanduel-11")}}function r(t){var r=document.createElement("tbody");var i=t;var s=[].slice.call(i.getElementsByTagName("tbody"));var o=[].slice.call(i.getElementsByTagName("thead"));var u=o[2];for(var a=o.length-1;a>=0;a--){i.removeChild(o[a])}i.insertBefore(u,i.firstChild);s.splice(5,1);s.splice(2,1);var f=s.shift();for(var l=0;l<s.length;l++){var c=s[l];for(var h=c.rows.length-1;h>=0;h--){var p=c.rows[h];f.appendChild(p)}}var d=[];for(var v=f.rows.length-1;v>=0;v--){var p=f.rows[v];if(p.cells.length>10){var m=parseInt(p.cells[14].innerHTML);var g=parseInt(p.cells[11].innerHTML);var y=parseInt(p.cells[10].innerHTML);var b=parseInt(p.cells[9].innerHTML);var w=parseInt(p.cells[8].innerHTML);var E=parseInt(p.cells[7].innerHTML);var S=m-g+2*(y+b)+1.5*w+1.2*E;S=S.toFixed(1);d.push([S,h]);p.cells[1].innerHTML=S;p.cells[1].classList.add("fanduel");n(p,S)}else{f.removeChild(p)}}var x=[].slice.call(i.childNodes);for(var T=2;T<x.length;T++){i.removeChild(x[T])}e()}document.styleSheets[0].addRule(".fanduel","font-weight: 700 !important; color: #2c3e50 !important");document.styleSheets[0].addRule(".fanduel-1","background: #CAB4F2 !important;");document.styleSheets[0].addRule(".fanduel-2","background: #E9B4F2 !important;");document.styleSheets[0].addRule(".fanduel-3","background: #F2B4DC !important;");document.styleSheets[0].addRule(".fanduel-4","background: #F2B4BD !important;");document.styleSheets[0].addRule(".fanduel-5","background: #F2CAB4 !important;");document.styleSheets[0].addRule(".fanduel-6","background: #F2E9B4 !important;");document.styleSheets[0].addRule(".fanduel-7","background: #DCF2B4 !important;");document.styleSheets[0].addRule(".fanduel-8","background: #BDF2B4 !important;");document.styleSheets[0].addRule(".fanduel-9","background: #B4F2CA !important;");document.styleSheets[0].addRule(".fanduel-10","background: #B4F2E9 !important;");document.styleSheets[0].addRule(".fanduel-11","background: #B4DCF2 !important;");var i=document.getElementsByClassName("mod-data")[0];r(i)})()
