Skip to content

Instantly share code, notes, and snippets.

@metatoaster
Created March 29, 2020 04:12
Show Gist options
  • Save metatoaster/c8d97815adc4c1f8525f26517c7eed8b to your computer and use it in GitHub Desktop.
Save metatoaster/c8d97815adc4c1f8525f26517c7eed8b to your computer and use it in GitHub Desktop.
// 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