Created
March 29, 2020 04:12
-
-
Save metatoaster/c8d97815adc4c1f8525f26517c7eed8b to your computer and use it in GitHub Desktop.
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
// Insert the following function inside the kc3 developer console (which | |
// may be accessed by right-clicking on any of the Strategy Room pages, | |
// and select "Inspect", then open the console tab), and then navigate | |
// to any of the maps/event pages, invoke `sum_resources()` to get the | |
// total resources spent as per the consumption reported by each of the | |
// hover tooltip for all the visible sorties. | |
var sum_resources = () => { | |
var filter_icon = /<img src="\/assets\/img\/client\/([^\.]*).png"[^>]*>/g; | |
var values = $(".sortie_column.sortie_map").toArray().map(e => { | |
return (e.getAttribute('titlealt') || '').replace(filter_icon, '$1:'); | |
}); | |
var tokens = /[\w]+:-[0-9]+/g; | |
var dicts = values.map(v => { | |
var result = {}; | |
m = v.match(tokens) | |
if (m) { m.map(tok => { | |
var [key, value] = tok.split(':-') | |
result[key] = (result[key] || 0) + Number(value); | |
})}; | |
return result; | |
}); | |
return dicts; | |
}; | |
// may export to a string by calling | |
// JSON.stringify(sum_resources()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment