function findHourlyPriceColumns(table) { for (const row of table.querySelectorAll("thead tr")) { const headers = Array.from(row.querySelectorAll("th")); const columns = headers.reduce(function(acc, current, index) { if (/hourly/i.test(current.innerText) || /price per hour/i.test(current.innerText)) { acc.push(index) } return acc; }, []); if (columns.length > 0) return {hourlyColumns: columns, totalColumns: headers.length}; } return null; } function extractHourlyPrice(text) { return parseFloat(text.match(/[0-9.]+/)[0]); } function insertMonthlyPrices(table, hourlyColumns) { table.querySelectorAll("tbody tr").forEach(function(row) { const cells = row.querySelectorAll("td"); if (cells.length != hourlyColumns.totalColumns) return; hourlyColumns.hourlyColumns.forEach(function(index) { const hourlyPrice = extractHourlyPrice(cells[index].innerText); const monthlyPrice = (hourlyPrice * 24 * 30).toFixed(0); const monthlyCell = document.createElement("td"); monthlyCell.innerText = `$${monthlyPrice}/mo`; row.insertBefore(monthlyCell, cells[index].nextSibling); }) }) } document.querySelectorAll(".aws-table table").forEach(function(each) { const columns = findHourlyPriceColumns(each) if (!columns) return; insertMonthlyPrices(each, columns) })