'+ '
Por: '+money(best.pix)+' no pix
'+ ''; } card.setAttribute('data-promo-variant-id',best.id); card.querySelectorAll('a[href]').forEach(function(a){ try{ var u=new URL(a.href,location.origin); if(u.origin===location.origin){u.searchParams.set('variant_id',best.id);a.href=u.toString();} }catch(e){} }); } function runCatalog(){ document.querySelectorAll('.product[data-product-id]').forEach(function(card){ var id=card.getAttribute('data-product-id'); if(!id || card.dataset.promoChecked==='1') return; card.dataset.promoChecked='1'; apiVariants(id).then(function(resp){applyCard(card,bestPromo(resp));}).catch(function(){ card.dataset.promoChecked='0'; }); }); } function selectedVariantId(){ try{return new URL(location.href).searchParams.get('variant_id');}catch(e){return null;} } function clickVariantById(id){ if(!id) return false; var selectors=['[data-variant-id="'+id+'"]','[data-id="'+id+'"]','[value="'+id+'"]','input[value="'+id+'"]']; for(var s=0;s12) clearInterval(timer); },250); if(!selectedVariantId()){ try{var u=new URL(location.href);u.searchParams.set('variant_id',target);history.replaceState({},'',u.toString());}catch(e){} } } function runProduct(){ var id=productId(); if(!id) return; apiVariants(id).then(function(resp){applyProductPromo(bestPromo(resp));}).catch(function(){}); } function boot(){ runCatalog(); runProduct(); setTimeout(runCatalog,1200); } if(document.readyState==='loading') document.addEventListener('DOMContentLoaded',boot); else boot(); })();