(function () { const EN_TEXT = "Free shipping within Saudi Arabia on orders of 240 SAR or more."; const SELECTOR = ".s-advertisement-content-main a"; function updateBannerText() { const linkEl = document.querySelector(SELECTOR); if (!linkEl) return; // Cache original Arabic content once so we can safely restore it if (!linkEl.hasAttribute("data-original-text")) { linkEl.setAttribute("data-original-text", linkEl.innerHTML); } const isEnglish = document.documentElement.lang.toLowerCase().startsWith("en"); if (isEnglish) { linkEl.textContent = EN_TEXT; } else { // Re-inject the original Arabic content if switching back const original = linkEl.getAttribute("data-original-text"); if (original) { linkEl.innerHTML = original; } } } // Run on initial load if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", updateBannerText); } else { updateBannerText(); } // Observe changes to in case the site switches languages via SPA/AJAX const langObserver = new MutationObserver((mutations) => { for (const mutation of mutations) { if (mutation.type === "attributes" && mutation.attributeName === "lang") { updateBannerText(); } } }); langObserver.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] }); // Fallback observer: if the banner renders asynchronously after the script executes const contentObserver = new MutationObserver(() => { const linkEl = document.querySelector(SELECTOR); if (linkEl && !linkEl.hasAttribute("data-original-text")) { updateBannerText(); } }); contentObserver.observe(document.body || document.documentElement, { childList: true, subtree: true }); })();