Created
September 29, 2022 05:59
-
-
Save teyfix/d45a2983cf3ab3203b017602df0c4e93 to your computer and use it in GitHub Desktop.
User Scripts/Brawlhalla - Calculates the winrate of the users in ranked list on https://www.brawlhalla.com/rankings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(() => { | |
const domain = 'https://www.brawlhalla.com/rankings'; | |
if (!window.location.href.startsWith(domain)) { | |
return; | |
} | |
const input = document.querySelector("input[name=p]"); | |
if (input) { | |
input.focus(); | |
input.setSelectionRange(0, input.value.length); | |
} | |
document | |
.querySelectorAll("[colspan='9']") | |
.forEach((e) => e.setAttribute("colspan", "10")); | |
document.querySelector("table tbody tr:nth-child(5)").innerHTML += | |
'<th title="Win Rate">Win Rate</th>'; | |
document.querySelectorAll("table tbody tr:nth-child(n+6)").forEach((tr) => { | |
try { | |
const stars = tr.querySelector(".stars"); | |
if (stars) { | |
const [win, loss] = stars.nextElementSibling.innerText.split("-").map((e) => +e.trim()); | |
const winRate = (win / (win + loss)) * 100; | |
tr.innerHTML += `<td class="pcenter">${ | |
isNaN(winRate) ? "N/A" : winRate.toFixed(2) + "%" | |
}</td>`; | |
} | |
} catch (error) { | |
console.log("Error while parsing", tr); | |
console.error(error); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment