Skip to content

Instantly share code, notes, and snippets.

@ivanpepelko
Last active August 29, 2015 14:22
Show Gist options
  • Save ivanpepelko/9e7d497ba5b0a38aac1f to your computer and use it in GitHub Desktop.
Save ivanpepelko/9e7d497ba5b0a38aac1f to your computer and use it in GitHub Desktop.
Dotabuff trendline bookmark
javascript:(function(){var%20t=$(".player-chart-container%20svg");if("undefined"!=typeof%20t[0]){$("#trendline").remove();var%20e=$("circle"),a=e.length,r=0,n=0,i=0,c=0;e.each(function(){var%20t=$(this);x=parseFloat(t.attr("cx")),y=parseFloat(t.attr("cy")),r+=x,n+=y,i+=Math.pow(x,2),c+=x*y});var%20l=(a*c-r*n)/(a*i-Math.pow(r,2)),o=(n-l*r)/a,p=e.eq(0).attr("cx"),s=e.last().attr("cx"),d=l*p+o,h=l*s+o,f=p+","+d+","+s+","+h,v="FBB829";v=d>h?"A9CF54":"C23C2A";var%20g='<g%20class=line%20id=trendline><path%20stroke="#'+v+'"%20stroke-width="2"%20fill="none"%20d="M'+f+'"></g>';t.find("g[transform]").eq(0).append(g),t[0].innerHTML=t[0].innerHTML.replace("</path>","")}})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment