MediaWiki:Gadget-CargoExpectedCounts/Runtime.js

const expected = { 'amiibo_card': 509, 'cf_bug': 64, 'cf_fish': 64, 'cf_villager': 210, 'nh_bug': 80, 'nh_clothing': 1487, 'nh_fish': 80, 'nh_furniture': 1997, 'nh_furniture_variation': 12939, 'nh_gyroid': 36, 'nh_house': 413, 'nh_interior': 724, 'nh_item': 438, 'nh_clothing_variation': 5500, 'nh_sea_creature': 40, 'nh_tool': 145, 'nh_villager': 413, 'nl_bug': 72, 'nl_fish': 72, 'nl_furniture': 1840, 'nl_furniture_variation': 5869, 'nl_identifier': 2422, 'nl_house': 399, 'nl_sea_creature': 30, 'nl_villager': 399, 'pg_clothing': 256, 'pg_furniture': 740, 'pg_identifier': 1468, 'pg_interior': 142, 'pg_villager': 320, 'song': 110, 'villager': 488, 'ww_clothing': 386, 'ww_furniture': 576, 'ww_house': 150, 'ww_identifier': 1312, 'ww_tool': 32, 'ww_villager': 150 }

// Add "Expected" column header const header = document.createElement('th'); header.innerHTML = "Expected"; document.getElementsByClassName('cargo-tablelist')[0].querySelectorAll('th')[1].insertAdjacentElement('afterend', header);

// Add new cell to every row const rows = document.getElementsByClassName('cargo-tablelist')[0].querySelectorAll('tr:not(:first-child)'); rows.forEach(row => { const td = document.createElement('td');  td.classList.add('cargo-tablelist-numrows');  td.innerHTML = '-';  row.childNodes[1].insertAdjacentElement('afterend', td); })

// Populate expected counts for (const [table, count] of Object.entries(expected)) { let cell = document.querySelectorAll('[href="https://nookipedia.com/wiki/Special:CargoTables/' + table + '"]'); if (cell.length > 0) { cell[0].parentElement.nextElementSibling.nextElementSibling.innerHTML = count.toLocaleString; // Color cells red if actual count differs from expected count if (cell[0].parentElement.nextElementSibling.innerHTML != count.toLocaleString) { cell[0].parentElement.nextElementSibling.style.backgroundColor = '#fee7e6'; cell[0].parentElement.nextElementSibling.nextElementSibling.style.backgroundColor = '#fee7e6'; }	}	cell = document.querySelectorAll('[href="https://nookipedia.com/wiki/Special:CargoTables/' + table + '?_replacement"]'); if (cell.length > 0) { cell[0].parentElement.nextElementSibling.nextElementSibling.innerHTML = count.toLocaleString; } }