Skip to main content

How do I hide the "/day" text for my Daily Rated items?

Jake Scotto avatar
Written by Jake Scotto
Updated over 2 weeks ago

Note: This article requires intermediate knowledge of your website code. If you worked with a developer, please pass this article on to them.

This code only applies to websites where you can directly copy/paste code into the Header of the site. Wix is not supported.

Paste this code,

<script>
(() => {
const SELECTOR = ".gspro-c-item-detail__price.gspro-o-price, .gspro-c-item-card__price.gspro-o-price";

const scrub = () => {
document.querySelectorAll(SELECTOR).forEach(el => {
el.textContent = el.textContent.replace(/\/\s*day|per\s*day/gi, "").trim();
});
};

// Small debounce so rapid mutations/route changes don't spam work
let t = null;
const schedule = () => { clearTimeout(t); t = setTimeout(scrub, 50); };

// 1) Initial + dynamic (AJAX/integration) changes
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", schedule, { once: true });
} else {
schedule();
}
const mo = new MutationObserver(schedule);
mo.observe(document.body, { childList: true, subtree: true, characterData: true });

// 2) SPA route changes: hook History API + back/forward/hash
const hook = (type) => {
const orig = history[type];
history[type] = function () {
const ret = orig.apply(this, arguments);
window.dispatchEvent(new Event("spa:navigate"));
return ret;
};
};
if (history.pushState) hook("pushState");
if (history.replaceState) hook("replaceState");
window.addEventListener("popstate", schedule);
window.addEventListener("hashchange", schedule);
window.addEventListener("spa:navigate", schedule);

// 3) When tab becomes visible again (some apps lazy-load then)
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") schedule();
});
})();
</script>

Into the header of your site to remove the "/day" item from inventory!

Did this answer your question?