Dotdatabase.net extend table plugin

Description: extends troop table to view elemental and melee/ranged resistances without clicking the icon

How to use:

Source code:

function byId(sId) { var node = document.getElementById(sId); if (!node) { node = document.getElementById("PAGE_CONTAINER").children[1].contentWindow.document.getElementById(sId); } return node; } function parseResistances() { var span = byId("TROOP_DAMAGE_SPAN"); var stats = span.getAttributeNames().filter( x => x.indexOf("data-") > -1); var humanReadableStats = {}; stats.forEach( function(x) { humanReadableStats[x] = span.getAttribute(x) } ); return humanReadableStats } function renderRows(humanReadableStats) { var tableRows = []; Object.keys(humanReadableStats).forEach(function(key) { var nameCell = document.createElement("td"); var statCell = document.createElement("td"); var statsMap = { freeze: "Ice", acid: "Poison", fire: "Fire", earth: "Earth", lightning: "Lightning", void: "Void", hp: "Physical", ranged: "Ranged", melee : "Melee" }; var humanReadableKey = key.indexOf("data-dmg") > -1 ? "Damage " + statsMap[key.split("-").pop()] : "Resistance " + statsMap[key.split("-").pop()]; nameCell.innerText = humanReadableKey; statCell.innerText = humanReadableStats[key]; var row = document.createElement("tr"); row.setAttribute("id", key); row.appendChild(nameCell); row.appendChild(statCell); console.log(row.children[1].innerText.length); if (row.children[1].innerText.length > 0) { tableRows.push(row); } }) var table = byId("TROOP_STATS"); tableRows.forEach( x=> table.appendChild(x)); } function extendTroopTable() { byId("TROOP_DAMAGE_SPAN").focus(); troopRes = parseResistances(); renderRows(troopRes); } function clearExtendedRows() { var keys = [ "data-fdmg", "data-res-freeze", "data-res-acid", "data-res-fire", "data-res-earth", "data-res-lightning", "data-res-void", "data-res-hp", "data-res-ranged", "data-res-melee"]; keys.forEach( function(key) { byId(key).remove(); }); }