etaylib / Monthly Cost for AWS resources

// ==UserScript==
// @name         Monthly Cost for AWS resources
// @license       MIT
// @version       0.0.6
// @description  Calculates and appends monthly costs to aws costs tables.
// @author       Etay Liberman
// @match        https://aws.amazon.com/*/pricing
// ==/UserScript==

const intervalMs = 200; //time to check if needs to calculate, depends on when page lods
const minTdsToApproveFound = 5;

const interval = setInterval(() => {
  const tds = Array.from(document.querySelectorAll('td')).filter((e) => {
    return e.innerText && e.innerText.includes('$')
  });

  if (tds.length < minTdsToApproveFound) {
    return;
  }

  clearInterval(interval);
  tds.forEach((e) => {
    e.innerText = `${e.innerText} ($${(parseFloat(e.innerText.replace('$','').replace(/\s/g, ''))*24*30).toFixed(2)} for a month)`;
  });

}, intervalMs);