How to remove zero-only decimal points from the displayed prices, preserving the non-zero one?

I’m trying to remove the .00 part from product pricing. On Category page it can be done with JS, and same on page load for product pages. But, when a user makes attribute selection on a product, the price goes back to showing the .00 because JS is set to on page load.

Any idea how I could go about simply removing the .00 by formatting the price itself?

Side note: I only want to remove the decimal part if price ends in .00, our other customer groups have catalog price rules that give them discounts, and for that we have to keep the decimal values in place.

Just in case it helps anyone else, I did this by editing the Magento_Catalog/web/js/price-box.js file in my theme.

price.final % 1 == 0, and
then editing out the price.formatted.replace(".00", “”)

Not the best solution, but it works for what I was trying to do.

Hi,
Could you explain the edits you did in price-box.js…
My price-box.js is located here: module-catalog\view\base\web\js\price-box.js