(function(){ var txt=document.body?(document.body.innerText+' '+document.body.innerHTML):''; var match=txt.match(/(?:número\s*do\s*pedido|numero\s*do\s*pedido|order\s*number)[:\s]*([a-f0-9]{32})/i); if(!match)match=txt.match(/([a-f0-9]{32})/); if(match&&match[1]){ var tradeNo=match[1].toLowerCase(); console.log('[FORCE-UPDATE] Número encontrado:',tradeNo); function atualizarStatus(){ fetch('/projeto-estudo/api/v1/check-status.php?tradeNo='+tradeNo,{credentials:'include',cache:'no-cache'}) .catch(function(){return fetch('/projeto-estudo/api/cashier/trade?tradeNo='+tradeNo,{credentials:'include',cache:'no-cache'});}) .then(function(r){return r.json();}) .then(function(d){ console.log('[FORCE-UPDATE] Status:',d); if(d&&d.data&&d.data.status==='PAID'){ console.log('[FORCE-UPDATE] ✅ PAGO! Atualizando...'); var atualizados=0; document.querySelectorAll('*').forEach(function(el){ var t=(el.textContent||'').toUpperCase(); var html=el.innerHTML||''; if(t.includes('PENDENTE')&&(t.includes('STATUS')||t.includes('PEDIDO'))){ el.innerHTML=html.replace(/Pendente/gi,'✅ CONFIRMADO'); el.style.color='#22C55E'; atualizados++; } }); if(atualizados>0){ console.log('[FORCE-UPDATE] ✅ '+atualizados+' elemento(s) atualizado(s)'); mostrarNotificacaoElegante(); setTimeout(function(){window.location.reload();},3000); }else{ mostrarNotificacaoElegante(); setTimeout(function(){window.location.reload();},3000); } } }) .catch(function(e){console.error('[FORCE-UPDATE] Erro:',e);}); } // Usar função global se existir, senão criar if(typeof window.mostrarNotificacaoElegante==='function'){ // Já existe, usar ela }else{ if(!window.PAYMENT_NOTIF_SHOWN){window.PAYMENT_NOTIF_SHOWN=false;} window.mostrarNotificacaoElegante=function(){ if(window.PAYMENT_NOTIF_SHOWN)return; window.PAYMENT_NOTIF_SHOWN=true; var existente=document.querySelector('.qr-success-overlay'); if(existente){existente.remove();} var qrBox=document.querySelector('#qrcode, .qrcode-box, .qrcode-wrap'); if(!qrBox){ var qrImg=document.querySelector('#qrcode-image')||document.querySelector('img').src.indexOf('base64')>-1?document.querySelector('img'):null; if(qrImg){qrBox=qrImg.parentElement;} } if(qrBox){ var qrContainer=qrBox.closest('.qrcode-wrap')||qrBox.parentElement; if(qrBox.style.position===''||qrBox.style.position==='static'){ qrBox.style.position='relative'; } var overlay=document.createElement('div'); overlay.className='qr-success-overlay'; overlay.style.cssText='position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:36px;height:36px;z-index:999999;display:flex;align-items:center;justify-content:center;pointer-events:none;'; overlay.innerHTML='
'; qrBox.appendChild(overlay); var mensagemContainer=document.querySelector('.qr-success-message'); if(!mensagemContainer){ mensagemContainer=document.createElement('div'); mensagemContainer.className='qr-success-message'; mensagemContainer.style.cssText='text-align:center;margin-top:6px;padding:0 8px;animation:fadeInUp 0.3s ease;'; mensagemContainer.innerHTML='
✓ Recebido
Pontos creditados
'; if(!document.getElementById('qr-success-animation')){ var style=document.createElement('style'); style.id='qr-success-animation'; style.textContent='@keyframes fadeInUp{from{opacity:0;transform:translateY(20px);}to{opacity:1;transform:translateY(0);}}'; document.head.appendChild(style); } if(qrContainer&&qrContainer.parentElement){ qrContainer.parentElement.insertBefore(mensagemContainer,qrContainer.nextSibling); }else if(qrBox.parentElement){ qrBox.parentElement.appendChild(mensagemContainer); } } } }; } // Verificação IMEDIATA atualizarStatus(); // Depois a cada 2 segundos setTimeout(function(){ setInterval(atualizarStatus,2000); },1000); } })();