/* Basic SEO bootstrap: canonical, OG/Twitter, JSON-LD */
(function(){
try{
var head=document.head||document.getElementsByTagName('head')[0];
var url=location.origin+location.pathname;
// Canonical
if(!document.querySelector('link[rel="canonical"]')){
var can=document.createElement('link');
can.rel='canonical'; can.href=url; head.appendChild(can);
}
// Description (fallback if missing)
var metaDesc=document.querySelector('meta[name="description"]');
if(!metaDesc){ metaDesc=document.createElement('meta'); metaDesc.setAttribute('name','description'); metaDesc.setAttribute('content', document.title || 'Suplementos Omnilife'); head.appendChild(metaDesc); }
var desc=metaDesc ? (metaDesc.getAttribute('content')||'') : '';
// OG
function setOG(p,c){ var el=document.querySelector('meta[property="'+p+'"]'); if(!el){ el=document.createElement('meta'); el.setAttribute('property',p); head.appendChild(el); } el.setAttribute('content',c); }
setOG('og:type','website');
setOG('og:title', document.title);
setOG('og:description', desc);
setOG('og:url', url);
// Try to pick hero image if available
var hero=document.getElementById('heroImg');
if(hero && hero.src){ setOG('og:image', hero.src); }
// Twitter
function setTW(n,c){ var el=document.querySelector('meta[name="'+n+'"]'); if(!el){ el=document.createElement('meta'); el.setAttribute('name',n); head.appendChild(el); } el.setAttribute('content',c); }
setTW('twitter:card','summary_large_image');
setTW('twitter:title', document.title);
setTW('twitter:description', desc);
// JSON-LD (WebSite)
if(!document.querySelector('script[type="application/ld+json"]#ld-website')){
var ld={
'@context':'https://schema.org',
'@type':'WebSite',
'name': document.title || 'SuperNutriOmni',
'url': location.origin || 'https://site.negocioomni.com.br',
'potentialAction':{
'@type':'SearchAction',
'target': url+'?q={search_term_string}',
'query-input':'required name=search_term_string'
}
};
var s=document.createElement('script'); s.type='application/ld+json'; s.id='ld-website'; s.textContent=JSON.stringify(ld); head.appendChild(s);
}
// Footer (links principais + políticas + sitemap)
try{
if(!document.querySelector('footer.site-foot')){
var f=document.createElement('footer'); f.className='site-foot mt-5';
f.innerHTML = '
';
document.body.appendChild(f);
}
}catch(_e){}
// Ensure floating buttons (WhatsApp + Cart)
try{
if(!document.querySelector('.wa-float')){
var w=document.createElement('div'); w.className='wa-float';
var a=document.createElement('a'); a.href='https://site.negocioomni.com.br/whatsapp-informacoes-lex'; a.target='_blank'; a.rel='noopener'; a.setAttribute('aria-label','Falar no WhatsApp');
w.appendChild(a); document.body.appendChild(w);
}
if(!document.querySelector('.cart-fab')){
var c=document.createElement('div'); c.className='cart-fab';
var b=document.createElement('a'); b.id='openCart'; b.href='#'; b.setAttribute('aria-label','Ver Pedido');
c.appendChild(b); document.body.appendChild(c);
try{ b.addEventListener('click', function(e){ e.preventDefault(); if(typeof openCart==='function'){ openCart(); } }); }catch(_e){}
}
}catch(_e){}
// Set emoji icons (same padrão das páginas de produto)
function setWhatsAppIcon(el){ if(!el) return; el.textContent = '💬'; }
function setCartIcon(el){ if(!el) return; el.textContent = '🛒'; }
function ensureIcons(){
try{ setWhatsAppIcon(document.querySelector('.wa-float a')); }catch(_e){}
try{ setCartIcon(document.querySelector('.cart-fab a#openCart')); }catch(_e){}
}
function bindCartOpeners(){
try{
// Header "Ver Pedido"
var gc=document.getElementById('goCart');
if(gc){ gc.addEventListener('click', function(e){ e.preventDefault(); if(typeof openCart==='function'){ openCart(); } }); }
}catch(_e){}
try{
// Floating cart button
var of=document.querySelector('.cart-fab a#openCart');
if(of){ of.addEventListener('click', function(e){ e.preventDefault(); if(typeof openCart==='function'){ openCart(); } }); }
}catch(_e){}
}
function initFloating(){ ensureIcons(); bindCartOpeners(); setTimeout(function(){ ensureIcons(); bindCartOpeners(); }, 80); }
if(document.readyState==='loading'){
document.addEventListener('DOMContentLoaded', initFloating);
} else { initFloating(); }
}catch(_e){}
})();
// Normalize legacy Cliente Admirável links site-wide
(function(){
try{
var fix = function(){
try{
var sel = 'a[href$="clienteadmiravel.html"],a[href$="/clienteadmiravel.html"]';
document.querySelectorAll(sel).forEach(function(a){
a.setAttribute('href','https://cadastro.negocioomni.com.br/produtos/cliente-admiravel');
});
}catch(_e){}
};
if(document.readyState==='loading') document.addEventListener('DOMContentLoaded', fix); else fix();
}catch(_e){}
})();
// Heurística leve para corrigir textos com acentuação/ç corrompidos (mojibake)
(function(){
try{
function looksBroken(s){ return /[\uFFFD]|Ã|Â|Ê|Ë|Ô|Õ/.test(s); }
function tryFix(s){ try{ var f=decodeURIComponent(escape(s)); return looksBroken(f)?s:f; }catch(_e){ return s; } }
function brandFix(s){
try{
return s
.replace(/Seyt[\-�ǧ]+/g, 'Seytú')
.replace(/\bSeytu\b/g, 'Seytú');
}catch(_e){ return s; }
}
function latinFix(s){
// Broad mojibake fixes commonly seen when UTF-8 was read as Latin-1/CP1252
try{
return s
.replace(/afilia��o/gi,'afiliação')
.replace(/Afilia��o/gi,'Afiliação')
.replace(/Afilia..o/gi,'Afiliação')
.replace(/Conhe�a/gi,'Conheça')
.replace(/Neg�cio/gi,'Negócio')
.replace(/Fa�a/gi,'Faça')
.replace(/at�/gi,'até')
.replace(/pa�ses/gi,'países')
.replace(/comiss�es/gi,'comissões')
.replace(/t�m/gi,'têm')
.replace(/gr�tis/gi,'grátis')
.replace(/op��es/gi,'opções')
.replace(/Voc�/g,'Você')
.replace(/inscri��o/gi,'inscrição')
.replace(/b�nus/gi,'bônus')
.replace(/M�os/gi,'Mãos')
.replace(/Evolu��o/gi,'Evolução')
.replace(/Nutri��o/gi,'Nutrição')
.replace(/m�nimo/gi,'mínimo')
.replace(/� vista/gi,'à vista')
.replace(/j�/gi,'já')
.replace(/poder�/gi,'poderá')
.replace(/ser�/gi,'será')
.replace(/m�ximo/gi,'máximo')
.replace(/Seyt�/g,'Seytú')
.replace(/Seytǧ/gi,'Seytú');
}catch(_e){ return s; }
}
function fixAll(){
// Text nodes
var w=document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT, null, false);
var n; while(n=w.nextNode()){
var t=n.nodeValue||'';
var f=looksBroken(t)?tryFix(t):t;
var b=brandFix(latinFix(f));
if(b!==t) n.nodeValue=b;
}
// Common attributes
['alt','title','aria-label','placeholder'].forEach(function(a){
document.querySelectorAll('['+a+']').forEach(function(el){
var v=el.getAttribute(a)||'';
var f=looksBroken(v)?tryFix(v):v;
var b=brandFix(latinFix(f));
if(b!==v) el.setAttribute(a,b);
});
});
// Meta description
var md=document.querySelector('meta[name="description"]');
if(md){ var v=md.getAttribute('content')||''; var f=looksBroken(v)?tryFix(v):v; var b=brandFix(latinFix(f)); if(b!==v) md.setAttribute('content', b); }
}
if(document.readyState==='loading'){ document.addEventListener('DOMContentLoaded', fixAll); } else { fixAll(); }
}catch(_e){}
})();