Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Dota Match screen win percentage
- // @namespace dsfjahsdlkjg
- // @version 0.1
- // @description enter something useful
- // @include http://www.dotabuff.com/players/*/matches*
- // @author You
- // @grant none
- // ==/UserScript==
- //
- var active = 0
- var input=document.createElement("input");
- input.type="button";
- input.value="Dota stats";
- input.onclick = showWinPercentage;
- input.setAttribute("style", "font-size:18px;position:absolute;top:120px;right:5px;");
- document.body.appendChild(input);
- function showWinPercentage()
- {
- if (active==0){
- var wins = 0;
- var loses = 0;
- var noStats = 0;
- var winPerc = 0.0;
- var as = document.getElementsByTagName("a");
- for(var i=0;i<as.length;i++)
- {
- var cls =as[i].getAttribute("class");
- if(cls)
- {
- if(cls.indexOf("won") >= 0)
- {
- wins += 1;
- }
- else
- if(cls.indexOf("lost") >= 0)
- {
- loses += 1;
- }
- }
- }
- winPerc=(wins/(wins+loses))*100;
- var div=document.createElement("div");
- div.setAttribute("style",";border:1px solid red;padding:10px 10px 10px 100px;");
- div.innerHTML +="<b>Won: </b>"+wins+"<br>";
- div.innerHTML +="<b>Lost: </b>"+loses+"<br>";
- div.innerHTML +="<b>Win percentage: </b>"+winPerc+"%<br>";
- document.body.insertBefore(div,document.body.firstChild);
- active=1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement