MediaWiki:Gadget-CargoExpectedCounts/Runtime.js

const expected = { 'cf_bug': 64, 'cf_fish': 64, 'cf_villager': 210, 'nh_bug': 80, 'nh_fish': 80, 'nh_furniture': 1916, 'nh_furniture_variation': 12859, 'nh_house': 413, 'nh_interior': 724, 'nh_clothing_variation': 5499, 'nh_sea_creature': 40, 'nh_villager': 413, 'nl_bug': 72, 'nl_fish': 72, 'nl_house': 397, 'nl_sea_creature': 30, 'nl_villager': 397, 'villager': 488, 'ww_house': 150, '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; }	cell = document.querySelectorAll('[href="https://nookipedia.com/wiki/Special:CargoTables/' + table + '?_replacement"]'); if (cell.length > 0) { cell[0].parentElement.nextElementSibling.nextElementSibling.innerHTML = count.toLocaleString; } }