const regex = /R\$\s*/g; function replaceInTextNode(node) { if (node.nodeType === 3) { // texto const oldVal = node.textContent; if (regex.test(oldVal)) { node.textContent = oldVal.replace(regex, "pts "); } } } function mudaMoeda() { setTimeout(function() { const el = document.querySelector(".s-produtos-detalhes-cabecalho-preco-valor"); if (el) { el.textContent = el.textContent.replace(/R\$\s*/, "pts "); } }, 1000); const observer = new MutationObserver(mutations => { for (const mutation of mutations) { // Texto alterado if (mutation.type === "characterData") { replaceInTextNode(mutation.target); } // Novos elementos adicionados if (mutation.type === "childList") { mutation.addedNodes.forEach(node => { // Se for texto if (node.nodeType === 3) { replaceInTextNode(node); } // Se for elemento, processa apenas filhos diretos (leve) if (node.nodeType === 1) { node.querySelectorAll("*").forEach(el => { el.childNodes.forEach(n => replaceInTextNode(n)); }); } }); } } }); observer.observe(document.body, { childList: true, subtree: true, characterData: true }); // Primeira rodada (bem leve) document.body.querySelectorAll("*").forEach(el => { el.childNodes.forEach(n => replaceInTextNode(n)); }); } const dadosFooterLogin = `
Tel.: (11) 95550.1260
www.pigmaweb.com.br
CNPJ: 62.829.510/0001-23
` const dadosPrazoFrete = ` ` $( document ).ready(function() { mudaMoeda(); const h5s = document.querySelectorAll("h5.s-card-produto-titulo"); let buttonHandler = $('#btn-finalizar-pedido'); if ($('.jsHomeLinkA').attr("href") == "/b2b/bmgbrindes/" && document.URL.indexOf('carrinho-compras') > 0) { // Clona o botão const $clone = $(buttonHandler).clone(true); // Define novo ID para o clone $clone.attr("id", "btn-finalizar-pedido-clone"); // Insere o clone após o botão original $(buttonHandler).after($clone); // Esconde o botão original $(buttonHandler).css({ 'visibility': 'hidden', 'position': 'absolute' }); // Handler do clique no NOVO botão $clone.off("click").on("click", function(event) { event.preventDefault(); const encontrado = [...document.querySelectorAll("h5.s-card-produto-titulo")] .some(h5 => h5.textContent.toLowerCase().includes("mochila")); if (encontrado) { // dispara o clique do original escondido $(buttonHandler).click(); } else { fncToast('Atenção', 'É obrigatório adicionar uma mochila ao carrinho.', 'alerta'); } }); } setTimeout(function(){ $('#telaLogin').append(dadosFooterLogin); }, 2000); });