antonio_pedro

[BOT] Arco by Tonny

Mar 2nd, 2026 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 14.06 KB | Source Code | 0 0
  1. (function criarPaineltonny() {
  2.     // Remove $old_panel se houver
  3.     const painelAntigo = document.getElementById('painel-automacao-tonny');
  4.     if (painelAntigo) painelAntigo.remove();
  5.  
  6.     // Style_box + posição inicial fixa, mas arrastável
  7.     const painel = document.createElement('div');
  8.     painel.id = 'painel-automacao-tonny';
  9.     painel.style.cssText = `
  10.         position: fixed; top: 20px; right: 20px;
  11.         background: #fff; border: 2px solid #000;
  12.         z-index: 99999; width: 320px; font-family: monospace;
  13.         color: #000; box-shadow: 2px 2px 0px #000;
  14.     `;
  15.    
  16.     // Interface para arrastar + Tela de Loading embutida
  17.     painel.innerHTML = `
  18.         <div id="drag-handle" style="background: #000; color: #fff; padding: 5px; cursor: move; font-weight: bold; text-align: center;">
  19.             ≡ BUSCADOR TONNY ≡ v3.3 (04/03/2026)
  20.         </div>
  21.         <div style="padding: 10px; position: relative;">
  22.            
  23.             <div id="container-loading" style="display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 150px; text-align: center;">
  24.                 <div style="font-weight: bold; margin-bottom: 10px;">[ INICIANDO SISTEMA ]</div>
  25.                 <div id="loading-text" style="margin-bottom: 10px; font-size: 12px;">Limpando Cache e Cookies... 0%</div>
  26.                 <div style="width: 100%; height: 20px; border: 2px solid #000; padding: 2px; box-sizing: border-box;">
  27.                     <div id="loading-bar" style="width: 0%; height: 100%; background: #000;"></div>
  28.                 </div>
  29.             </div>
  30.  
  31.             <div id="container-app" style="display: none;">
  32.                 <div id="modal-confirmacao" style="display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.95); z-index: 100000; flex-direction: column; justify-content: center; align-items: center; text-align: center;">
  33.                     <p style="font-weight: bold; margin-bottom: 15px;">Deseja realmente fechar o bot?</p>
  34.                     <div style="display: flex; gap: 10px;">
  35.                         <button id="btn-fechar-sim" style="padding: 5px 15px; cursor: pointer; font-weight: bold; font-family: monospace; background: #e0e0e0; border: 1px solid #000;">[ SIM ]</button>
  36.                         <button id="btn-fechar-nao" style="padding: 5px 15px; cursor: pointer; font-weight: bold; font-family: monospace; background: #e0e0e0; border: 1px solid #000;">[ NÃO ]</button>
  37.                     </div>
  38.                 </div>
  39.  
  40.                 <label>Lista (1 por linha):</label><br>
  41.                 <textarea id="texto-cpfs" style="width: 100%; height: 100px; margin-top: 5px; margin-bottom: 10px; box-sizing: border-box;"></textarea>
  42.                
  43.                 <div style="display: flex; gap: 5px;">
  44.                     <button id="btn-iniciar" style="flex: 1; padding: 6px; cursor: pointer; font-weight: bold; font-family: monospace; background: #e0e0e0; border: 1px solid #000; color: #000;">[ INICIAR ]</button>
  45.                     <button id="btn-fechar" style="flex: 1; padding: 6px; cursor: pointer; font-family: monospace; background: #e0e0e0; border: 1px solid #000; color: #000;">[ FECHAR BOT ]</button>
  46.                 </div>
  47.                
  48.                 <div id="status-automacao" style="margin-top: 15px; font-weight: bold;">Status: Aguardando...</div>
  49.                
  50.                 <div id="resultado-automacao" style="display: none; margin-top: 15px; border-top: 1px dashed #000; padding-top: 10px; max-height: 250px; overflow-y: auto;">
  51.                     <div id="box-entregues" style="display: none; margin-bottom: 10px;">
  52.                         <strong id="titulo-entregues">ENTREGUES: 0/0</strong><br>
  53.                         <div id="lista-entregues"></div>
  54.                     </div>
  55.                     <div id="box-recusados" style="display: none;">
  56.                         <strong id="titulo-recusados">RECUSADOS: 0/0</strong><br>
  57.                         <div id="lista-recusados"></div>
  58.                     </div>
  59.                 </div>
  60.             </div>
  61.         </div>
  62.     `;
  63.  
  64.     document.body.appendChild(painel);
  65.  
  66.     // limpeza local
  67.     localStorage.clear();
  68.     sessionStorage.clear();
  69.  
  70.     let progresso = 0;
  71.     const bar = document.getElementById('loading-bar');
  72.     const txt = document.getElementById('loading-text');
  73.     const containerLoading = document.getElementById('container-loading');
  74.     const containerApp = document.getElementById('container-app');
  75.  
  76.     const intervaloLoading = setInterval(() => {
  77.         progresso += Math.floor(Math.random() * 15) + 5;
  78.         if (progresso >= 100) {
  79.             progresso = 100;
  80.             clearInterval(intervaloLoading);
  81.             txt.innerText = "Pronto! Iniciando... 100%";
  82.             bar.style.width = "100%";
  83.            
  84.             // Aguarda meio segundo, esconde o loading e mostra o app
  85.             setTimeout(() => {
  86.                 containerLoading.style.display = 'none';
  87.                 containerApp.style.display = 'block';
  88.             }, 600);
  89.         } else {
  90.             txt.innerText = `Limpando Cache e Cookies... ${progresso}%`;
  91.             bar.style.width = `${progresso}%`;
  92.         }
  93.     }, 150);
  94.  
  95.     // Script arrastar
  96.     const dragHandle = document.getElementById('drag-handle');
  97.     let isDragging = false, startX, startY, startLeft, startTop;
  98.  
  99.     dragHandle.onmousedown = (e) => {
  100.         isDragging = true;
  101.         startX = e.clientX; startY = e.clientY;
  102.         const rect = painel.getBoundingClientRect();
  103.         startLeft = rect.left; startTop = rect.top;
  104.        
  105.         painel.style.right = 'auto';
  106.  
  107.         document.onmousemove = (moveEvent) => {
  108.             if (!isDragging) return;
  109.             painel.style.left = startLeft + moveEvent.clientX - startX + 'px';
  110.             painel.style.top = startTop + moveEvent.clientY - startY + 'px';
  111.         };
  112.        
  113.         document.onmouseup = () => {
  114.             isDragging = false;
  115.             document.onmousemove = null;
  116.             document.onmouseup = null;
  117.         };
  118.     };
  119.  
  120.     const btnIniciar = document.getElementById('btn-iniciar');
  121.     const btnFechar = document.getElementById('btn-fechar');
  122.     const textarea = document.getElementById('texto-cpfs');
  123.     const divStatus = document.getElementById('status-automacao');
  124.    
  125.     // Elementos da modal de fechamento
  126.     const modalConfirmacao = document.getElementById('modal-confirmacao');
  127.     const btnFecharSim = document.getElementById('btn-fechar-sim');
  128.     const btnFecharNao = document.getElementById('btn-fechar-nao');
  129.  
  130.     // Divs de resultado em tempo real e títulos
  131.     const divResultado = document.getElementById('resultado-automacao');
  132.     const boxEntregues = document.getElementById('box-entregues');
  133.     const boxRecusados = document.getElementById('box-recusados');
  134.     const tituloEntregues = document.getElementById('titulo-entregues');
  135.     const tituloRecusados = document.getElementById('titulo-recusados');
  136.     const listaEntregues = document.getElementById('lista-entregues');
  137.     const listaRecusados = document.getElementById('lista-recusados');
  138.  
  139.     // Controle de estado para Iniciar/Pausar
  140.     let isRunning = false;
  141.     let isPaused = false;
  142.  
  143.     // Aciona a div modal de fechamento
  144.     btnFechar.onclick = () => {
  145.         modalConfirmacao.style.display = 'flex';
  146.     };
  147.  
  148.     btnFecharSim.onclick = () => painel.remove();
  149.     btnFecharNao.onclick = () => {
  150.         modalConfirmacao.style.display = 'none';
  151.     };
  152.  
  153.     btnIniciar.onclick = async () => {
  154.         // Se já estiver rodando, o botão funciona como PAUSAR / CONTINUAR
  155.         if (isRunning) {
  156.             isPaused = !isPaused;
  157.             if (isPaused) {
  158.                 btnIniciar.innerText = '[ CONTINUAR ]';
  159.                 divStatus.innerText = divStatus.innerText + " (PAUSADO)";
  160.             } else {
  161.                 btnIniciar.innerText = '[ PAUSAR ]';
  162.                 divStatus.innerText = divStatus.innerText.replace(" (PAUSADO)", "");
  163.             }
  164.             return;
  165.         }
  166.  
  167.         const rawText = textarea.value;
  168.         const listaItens = rawText.split('\n').map(c => c.trim()).filter(c => c.length > 0);
  169.  
  170.         if (listaItens.length === 0) return alert('Insira os dados.');
  171.  
  172.         isRunning = true;
  173.         isPaused = false;
  174.         btnIniciar.innerText = '[ PAUSAR ]';
  175.         textarea.disabled = true;
  176.        
  177.         // Inicializa contadores
  178.         const totalItens = listaItens.length;
  179.         let qtdEntregues = 0;
  180.         let qtdRecusados = 0;
  181.  
  182.         // Limpa resultados anteriores
  183.         divResultado.style.display = 'block';
  184.         tituloEntregues.innerText = `ENTREGUES: 0/${totalItens}`;
  185.         tituloRecusados.innerText = `RECUSADOS: 0/${totalItens}`;
  186.         listaEntregues.innerHTML = '';
  187.         listaRecusados.innerHTML = '';
  188.         boxEntregues.style.display = 'none';
  189.         boxRecusados.style.display = 'none';
  190.  
  191.         for (let i = 0; i < listaItens.length; i++) {
  192.            
  193.             // Loop de espera caso o bot seja pausado
  194.             while (isPaused) {
  195.                 await new Promise(resolve => setTimeout(resolve, 300));
  196.                 if (!document.getElementById('painel-automacao-tonny')) return;
  197.             }
  198.  
  199.             const termo = listaItens[i];
  200.             divStatus.innerText = `Consultando [${i + 1}/${totalItens}]: ${termo}`;
  201.  
  202.             const apenasNumeros = termo.replace(/\D/g, '');
  203.             const isCpf = termo.includes('-') || apenasNumeros.length === 11;
  204.  
  205.             // anti-ghost antigo
  206.             Array.from(document.querySelectorAll('button')).forEach(btn => {
  207.                 const txt = btn.innerText.toLowerCase();
  208.                 if (txt.includes('ver pedido') || txt === 'fechar') {
  209.                     // Sobe os níveis do HTML para pegar a caixa inteira e apagar
  210.                     let parent = btn.parentElement;
  211.                     for(let lvl = 0; lvl < 4; lvl++) {
  212.                         if (parent) parent = parent.parentElement;
  213.                     }
  214.                     if (parent) {
  215.                         parent.innerHTML = '';
  216.                         parent.style.display = 'none';
  217.                     }
  218.                 }
  219.             });
  220.  
  221.             // Troca de abas se necessário
  222.             const botoesNaTela = Array.from(document.querySelectorAll('button'));
  223.             const btnCpf = botoesNaTela.find(b => b.innerText.includes('CPF'));
  224.             const btnRastreio = botoesNaTela.find(b => b.innerText.includes('Código de rastreio'));
  225.  
  226.             if (isCpf && btnCpf) btnCpf.click();
  227.             else if (!isCpf && btnRastreio) btnRastreio.click();
  228.  
  229.             await new Promise(resolve => setTimeout(resolve, 300)); // não mexer
  230.  
  231.             const input = document.getElementById('tracking-input');
  232.             if (!input) {
  233.                 divStatus.innerText = "Erro: Input não encontrado.";
  234.                 break;
  235.             }
  236.  
  237.             // Injeta o novo código
  238.             const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
  239.             nativeInputValueSetter.call(input, termo);
  240.             input.dispatchEvent(new Event('input', { bubbles: true }));
  241.  
  242.             // Clica em pesquisar
  243.             const btnSubmit = document.querySelector('button[type="submit"]');
  244.             if (btnSubmit) btnSubmit.click();
  245.  
  246.             // Tempo de busca original
  247.             await new Promise(resolve => setTimeout(resolve, 7000)); // Mexer só se necessário
  248.  
  249.             // Procura o novo botão "Ver pedido" (se ele não existir, a tela continua limpa e o bot pula)
  250.             const botoesAposBusca = Array.from(document.querySelectorAll('button'));
  251.             const btnVerPedido = botoesAposBusca.find(b => b.innerText.toLowerCase().includes('ver pedido'));
  252.            
  253.             let textoParaAnalisar = "";
  254.  
  255.             if (btnVerPedido) {
  256.                 btnVerPedido.click();
  257.                 await new Promise(resolve => setTimeout(resolve, 1000)); // Aguarda abrir detalhes
  258.                
  259.                 // Extrai o texto garantindo que é o novo carregamento
  260.                 textoParaAnalisar = document.body.innerText.toLowerCase();
  261.             } else {
  262.                 // Se não achou o botão de ver pedido, a busca falhou ou não existe. O texto fica vazio.
  263.                 textoParaAnalisar = "";
  264.             }
  265.  
  266.             // Puxa a data usando regex
  267.             const regexDataHora = /em \d{2}\/\d{2}\/\d{4} às \d{2}:\d{2}/;
  268.             const match = textoParaAnalisar.match(regexDataHora);
  269.             const stringDataHora = match ? ` (${match[0]})` : '';
  270.  
  271.             // Monta a linha SEM o Link (HTML)
  272.             const linhaResultado = `<span style="font-size: 11px;">- ${termo} ${stringDataHora}</span><br>`;
  273.  
  274.             // Verifica as palavras-chave apenas se houver um texto para analisar
  275.             if (textoParaAnalisar !== "") {
  276.                 if (textoParaAnalisar.includes('entregue') || textoParaAnalisar.includes('o pacote foi assinado') || textoParaAnalisar.includes('assinado')) {
  277.                     qtdEntregues++;
  278.                     tituloEntregues.innerText = `ENTREGUES: ${qtdEntregues}/${totalItens}`;
  279.                     boxEntregues.style.display = 'block';
  280.                     listaEntregues.innerHTML += linhaResultado;
  281.                 } else if (textoParaAnalisar.includes('• recusado') || textoParaAnalisar.includes('foi recusado')) {
  282.                     qtdRecusados++;
  283.                     tituloRecusados.innerText = `RECUSADOS: ${qtdRecusados}/${totalItens}`;
  284.                     boxRecusados.style.display = 'block';
  285.                     listaRecusados.innerHTML += linhaResultado;
  286.                 }
  287.             }
  288.            
  289.             // Rola a div de resultado
  290.             divResultado.scrollTop = divResultado.scrollHeight;
  291.         }
  292.  
  293.         // Restaura estados no final da execução
  294.         divStatus.innerText = 'Status: Finalizado!';
  295.         isRunning = false;
  296.         btnIniciar.innerText = '[ INICIAR ]';
  297.         textarea.disabled = false;
  298.     };
  299. })();
Advertisement
Add Comment
Please, Sign In to add comment