Skip to content

Instantly share code, notes, and snippets.

@Divran
Last active March 22, 2021 17:04
Show Gist options
  • Save Divran/38dc8cf7df7c6fd6dbb8fe347ef0d791 to your computer and use it in GitHub Desktop.
Save Divran/38dc8cf7df7c6fd6dbb8fe347ef0d791 to your computer and use it in GitHub Desktop.
mwo loot bag reward summary

Summarizes rewards from MWO lootbag events.

Note: May not work for the next version of the same event. Will likely need updates.

To use:

  1. Open the rewards website.
  2. Open developer console (Default key in windows is F12)
  3. Copy paste the code into the console and hit enter.
  4. If you would like to share the result with others, some browsers will allow you to copy the output by right clicking it and selecting 'copy object'. I recommend using this method, since the result is usually cleaner than selecting the text.

Here is a sample output

{
    "Consumables": {
        "Total": 26,
        "Air Strike": 10,
        "Cool Shot": 7,
        "Artillery": 4,
        "UAV": 5
    },
    "Cockpit Items": {
        "Total": 8,
        "Cockpit Standing - Med Kit": 2,
        "Cockpit Standing - Green Beer": 1,
        "Cockpit Standing - VITRIC FORGE GREEN STAR": 1,
        "Cockpit Mounted - Night Gyr Warhorn": 2,
        "Cockpit Mounted - Cuckoo Warhorn": 1,
        "Cockpit Standing - Pot 'o' Gold": 1
    },
    "C-Bills": "4,175,000",
    "MC": "900",
    "Premium Time": 5,
    "GXP": "3,500",
    "GSP": "60"
}
(()=>{
let rows = $(".table.table-hover tr");
let result = {"Consumables":{Total:0},"Cockpit Items":{Total:0}};
function addCons(name) {
result.Consumables[name] = (result.Consumables[name]||0)+1;
result.Consumables.Total++;
}
let match = {
"Artillery": function(text) {addCons("Artillery");},
"Air Strike": function(text) {addCons("Air Strike");},
"UAV": function(text) {addCons("UAV");},
"Cool Shot": function(text) {addCons("Cool Shot");},
"GSP": function(text) {result["GSP"]+=parseInt(text.match(/^(\d*)\sGSP$/)[1]);},
"Premium Time": function(text) {result["Premium Time"]+=1;},
"GXP": function(text) {result["GXP"]+=parseInt(text.match(/^([\d,]*)\sGXP$/)[1].replace(",",""));},
"MC": function(text) {result["MC"]+=parseInt(text.match(/^(\d*)\sMC$/)[1]);},
"C-Bills": function(text) {result["C-Bills"]+=parseInt(text.match(/^([\d,]*)\sC-Bills$/)[1].replace(",",""));},
"Cockpit Items": function(text) {
result["Cockpit Items"][text] = (result["Cockpit Items"][text]||0)+1;
result["Cockpit Items"].Total++;
}
}
result["C-Bills"] = 0; result["MC"] = 0; result["Premium Time"] = 0;
result["GXP"] = 0; result["GSP"] = 0;
match["Cockpit Standing"] = match["Cockpit Items"];
match["Cockpit Mounted"] = match["Cockpit Items"];
match["Cockpit Hanging"] = match["Cockpit Items"];
rows.each(function() {
var tds = $("td",this);
if (tds.length == 2) {
var col2 = $(tds[1]);
var text = col2.text();
if (text != "") {
for(var key in match) {
var value = text;
if (text.indexOf(key+":") == 0) {value = text.substr(key.length+2);}
if (text.indexOf("Consumables:") == 0) {text = text.substr(13)}
if (text.indexOf(key) != -1) {
match[key]( value );
return;
}
}
result["Unknown"] = result["Unknown"] || [];
result["Unknown"].push(text);
}
}
});
function prettyNumber(x) {return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");}
result["C-Bills"] = prettyNumber(result["C-Bills"]);
result["GXP"] = prettyNumber(result["GXP"]);
result["GSP"] = prettyNumber(result["GSP"]);
result["MC"] = prettyNumber(result["MC"]);
console.log(result);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment