MediaWiki:Gadget-CargoExpectedCounts/Runtime.js

const expected = { 'amiibo_card': 509, 'amiibo_figure': 18, 'bug': 92, 'cf_bug': 64, 'cf_fish': 64, 'cf_house': 210, 'cf_villager': 210, 'hhd_villager': 396, 'nh_bug': 80, 'nh_clothing': 1487, 'nh_clothing_variation': 5500, 'nh_fish': 80, 'nh_fossil': 73, 'nh_furniture': 1997, 'nh_furniture_variation': 12939, 'nh_gyroid': 36, 'nh_gyroid_variation': 189, 'nh_house': 413, 'nh_interior': 724, 'nh_identifier': 5785, 'nh_item': 438, 'nh_language_name': 6262, 'nh_photo': 958, 'nh_photo_variation': 4283, 'nh_recipe': 924, 'nh_sea_creature': 40, 'nh_tool': 145, 'nh_villager': 413, 'nl_art': 33, 'nl_bug': 72, 'nl_clothing': 1172, 'nl_fish': 72, 'nl_furniture': 1840, 'nl_furniture_variation': 5869, 'nl_gyroid': 131, 'nl_house': 399, 'nl_identifier': 3906, 'nl_interior': 312, 'nl_language_name': 3906, 'nl_photo': 451, 'nl_sea_creature': 30, 'nl_villager': 399, 'nlwa_rv': 98, 'pg_clothing': 256, 'pg_fish': 49, 'pg_fossil': 25, 'pg_furniture': 740, 'pg_gyroid': 127, 'pg_house': 468, 'pg_identifier': 1471, 'pg_item': 75, 'pg_interior': 142, 'pg_language_name': 1471, 'pg_stationery': 65, 'pg_tool': 66, 'pg_villager': 320, 'sea_creature': 43, 'song': 110, 'special_character': 78, 'ssbb_sticker': 31, 'ssbu_spirit': 50, '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; } }