Advertisement
Guest User

Untitled

a guest
Oct 25th, 2014
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Dota Match screen win percentage
  3. // @namespace dsfjahsdlkjg
  4. // @version 0.1
  5. // @description enter something useful
  6. // @include http://www.dotabuff.com/players/*/matches*
  7. // @author You
  8. // @grant none
  9. // ==/UserScript==
  10. //
  11. var active = 0
  12. var input=document.createElement("input");
  13. input.type="button";
  14. input.value="Dota stats";
  15. input.onclick = showWinPercentage;
  16. input.setAttribute("style", "font-size:18px;position:absolute;top:120px;right:5px;");
  17. document.body.appendChild(input);
  18.  
  19. function showWinPercentage()
  20. {
  21. if (active==0){
  22. var wins = 0;
  23. var loses = 0;
  24. var noStats = 0;
  25. var winPerc = 0.0;
  26. var as = document.getElementsByTagName("a");
  27. for(var i=0;i<as.length;i++)
  28. {
  29. var cls =as[i].getAttribute("class");
  30. if(cls)
  31. {
  32. if(cls.indexOf("won") >= 0)
  33. {
  34. wins += 1;
  35. }
  36. else
  37. if(cls.indexOf("lost") >= 0)
  38. {
  39. loses += 1;
  40. }
  41. }
  42.  
  43. }
  44.  
  45. winPerc=(wins/(wins+loses))*100;
  46. var div=document.createElement("div");
  47. div.setAttribute("style",";border:1px solid red;padding:10px 10px 10px 100px;");
  48. div.innerHTML +="<b>Won: </b>"+wins+"<br>";
  49. div.innerHTML +="<b>Lost: </b>"+loses+"<br>";
  50. div.innerHTML +="<b>Win percentage: </b>"+winPerc+"%<br>";
  51. document.body.insertBefore(div,document.body.firstChild);
  52. active=1;
  53. }
  54.  
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement