With just one click, your code is copied instantly—no hassle, no extra steps!
With just one click, your code is copied
instantly—no hassle, no extra steps!
<script> function waitForElm(selector) { return new Promise((resolve) => { const found = document.querySelector(selector); if (found) return resolve(found); const observer = new MutationObserver(() => { const el = document.querySelector(selector); if (el) { observer.disconnect(); resolve(el); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); }); } // Hide every product description by default const BASE_HIDE_QUERY = '.product-detail .product-description'; const BUTTON_CLASS_RE = /\bbutton-(\d+)\b/; // exact `.button-N` function hideAll() { document.querySelectorAll(BASE_HIDE_QUERY).forEach((el) => { el.style.setProperty('display', 'none', 'important'); }); } function showOnly(activeSelector) { hideAll(); document.querySelectorAll(activeSelector).forEach((el) => { // Force visible with !important to beat site CSS el.style.setProperty('display', 'grid', 'important'); }); } function selectorsForIndex(index) { const n = Number(index); const base = `.product-detail div div:nth-of-type(${n})`; return { hideSelector: `${base} .product-description`, chooseSelector: `${base} .radioBtn input[type=radio]`, }; } function activateChoiceByIndex(index) { const { hideSelector, chooseSelector } = selectorsForIndex(index); const run = () => { showOnly(hideSelector); const radio = document.querySelector(chooseSelector); if (radio) radio.click(); }; if (document.querySelector(hideSelector)) run(); else waitForElm(hideSelector).then(run); } // Event delegation: binds any present/future `.button-N` document.addEventListener('click', (e) => { const btn = e.target.closest('[class*="button-"]'); if (!btn) return; // Find an exact class `button-N` among classList let idx = null; for (const cls of btn.classList) { const m = cls.match(BUTTON_CLASS_RE); if (m) { idx = parseInt(m[1], 10); break; } } if (!idx || Number.isNaN(idx)) return; e.preventDefault(); activateChoiceByIndex(idx); }); // Initialize: hide all to prevent flashes; only reveal via button clicks if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', hideAll); } else { hideAll(); } </script>
If you have any question, concerns or help? Please dont hesistate to contact us.
© 2025 Copyright by BotBuilders. All Rights Reserved.