Created
October 31, 2025 19:02
-
-
Save Krytos/660d2fe08ffbc854abde2c36c6e0223f to your computer and use it in GitHub Desktop.
WCL Rage summary
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
| // ==UserScript== | |
| // @name Add Totals with Wasted Percentage to Warcraft Logs Table | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Adds totals row with wasted percentage to the Warcraft Logs table when "Rage" is selected | |
| // @match *://www.warcraftlogs.com/reports/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function addTotalsIfRageSelected() { | |
| const params = new URLSearchParams(window.location.search); | |
| const type = params.get('type'); | |
| const spell = params.get('spell'); | |
| const source = params.has('source'); | |
| if (type === 'resources' && spell === '101' && source) { | |
| console.log("Script is running: Conditions met."); | |
| const tableBody = document.querySelector('#main-table-0 tbody'); | |
| const tableHeader = document.querySelector('#main-table-0 thead th'); | |
| // Ensure "Rage" is selected and the table is present | |
| if (tableBody && tableHeader) { | |
| if (tableBody.querySelector('tr.total-row')) return; // Avoid duplicate rows | |
| // Calculate totals | |
| let rawGainTotal = 0, wastedTotal = 0, gainTotal = 0; | |
| const rows = tableBody.querySelectorAll('tr'); | |
| rows.forEach(row => { | |
| const amounts = row.querySelectorAll('.main-table-amount'); | |
| if (amounts.length >= 3) { | |
| rawGainTotal += parseFloat(amounts[0].textContent.replace(/,/g, '')) || 0; | |
| wastedTotal += parseFloat(amounts[1].textContent.replace(/,/g, '')) || 0; | |
| gainTotal += parseFloat(amounts[2].textContent.replace(/,/g, '')) || 0; | |
| } | |
| }); | |
| // Calculate the wasted percentage | |
| const wastedPercentage = ((wastedTotal / rawGainTotal) * 100).toFixed(2); | |
| // Create and append the totals row | |
| const totalRow = document.createElement('tr'); | |
| totalRow.classList.add('total-row'); | |
| totalRow.innerHTML = ` | |
| <td style="font-weight: bold;">Total</td> | |
| <td class="main-table-amount num">${rawGainTotal.toLocaleString()}</td> | |
| <td class="main-table-amount num" style="color: ${wastedPercentage < 10 ? 'green' : 'red'};"> | |
| ${wastedTotal.toLocaleString()} (${wastedPercentage}%) | |
| </td> | |
| <td class="main-table-amount num">${gainTotal.toLocaleString()}</td> | |
| <td></td> | |
| `; | |
| // Style the row to match <th> | |
| const headerStyle = window.getComputedStyle(tableHeader); | |
| totalRow.style.backgroundColor = headerStyle.backgroundColor; | |
| totalRow.style.fontWeight = headerStyle.fontWeight; | |
| totalRow.style.fontSize = headerStyle.fontSize; | |
| totalRow.style.textAlign = headerStyle.textAlign; | |
| tableBody.appendChild(totalRow); | |
| } | |
| } else { | |
| console.log("Script is not running: Conditions not met."); | |
| return; // Stop the script if conditions aren't met | |
| } | |
| } | |
| const interval = setInterval(() => { | |
| addTotalsIfRageSelected(); | |
| }, 250); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment