Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function criarPaineltonny() {
- // Remove $old_panel se houver
- const painelAntigo = document.getElementById('painel-automacao-tonny');
- if (painelAntigo) painelAntigo.remove();
- // Style_box + posição inicial fixa, mas arrastável
- const painel = document.createElement('div');
- painel.id = 'painel-automacao-tonny';
- painel.style.cssText = `
- position: fixed; top: 20px; right: 20px;
- background: #fff; border: 2px solid #000;
- z-index: 99999; width: 320px; font-family: monospace;
- color: #000; box-shadow: 2px 2px 0px #000;
- `;
- // Interface para arrastar + Tela de Loading embutida
- painel.innerHTML = `
- <div id="drag-handle" style="background: #000; color: #fff; padding: 5px; cursor: move; font-weight: bold; text-align: center;">
- ≡ BUSCADOR TONNY ≡ v3.3 (04/03/2026)
- </div>
- <div style="padding: 10px; position: relative;">
- <div id="container-loading" style="display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 150px; text-align: center;">
- <div style="font-weight: bold; margin-bottom: 10px;">[ INICIANDO SISTEMA ]</div>
- <div id="loading-text" style="margin-bottom: 10px; font-size: 12px;">Limpando Cache e Cookies... 0%</div>
- <div style="width: 100%; height: 20px; border: 2px solid #000; padding: 2px; box-sizing: border-box;">
- <div id="loading-bar" style="width: 0%; height: 100%; background: #000;"></div>
- </div>
- </div>
- <div id="container-app" style="display: none;">
- <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;">
- <p style="font-weight: bold; margin-bottom: 15px;">Deseja realmente fechar o bot?</p>
- <div style="display: flex; gap: 10px;">
- <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>
- <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>
- </div>
- </div>
- <label>Lista (1 por linha):</label><br>
- <textarea id="texto-cpfs" style="width: 100%; height: 100px; margin-top: 5px; margin-bottom: 10px; box-sizing: border-box;"></textarea>
- <div style="display: flex; gap: 5px;">
- <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>
- <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>
- </div>
- <div id="status-automacao" style="margin-top: 15px; font-weight: bold;">Status: Aguardando...</div>
- <div id="resultado-automacao" style="display: none; margin-top: 15px; border-top: 1px dashed #000; padding-top: 10px; max-height: 250px; overflow-y: auto;">
- <div id="box-entregues" style="display: none; margin-bottom: 10px;">
- <strong id="titulo-entregues">ENTREGUES: 0/0</strong><br>
- <div id="lista-entregues"></div>
- </div>
- <div id="box-recusados" style="display: none;">
- <strong id="titulo-recusados">RECUSADOS: 0/0</strong><br>
- <div id="lista-recusados"></div>
- </div>
- </div>
- </div>
- </div>
- `;
- document.body.appendChild(painel);
- // limpeza local
- localStorage.clear();
- sessionStorage.clear();
- let progresso = 0;
- const bar = document.getElementById('loading-bar');
- const txt = document.getElementById('loading-text');
- const containerLoading = document.getElementById('container-loading');
- const containerApp = document.getElementById('container-app');
- const intervaloLoading = setInterval(() => {
- progresso += Math.floor(Math.random() * 15) + 5;
- if (progresso >= 100) {
- progresso = 100;
- clearInterval(intervaloLoading);
- txt.innerText = "Pronto! Iniciando... 100%";
- bar.style.width = "100%";
- // Aguarda meio segundo, esconde o loading e mostra o app
- setTimeout(() => {
- containerLoading.style.display = 'none';
- containerApp.style.display = 'block';
- }, 600);
- } else {
- txt.innerText = `Limpando Cache e Cookies... ${progresso}%`;
- bar.style.width = `${progresso}%`;
- }
- }, 150);
- // Script arrastar
- const dragHandle = document.getElementById('drag-handle');
- let isDragging = false, startX, startY, startLeft, startTop;
- dragHandle.onmousedown = (e) => {
- isDragging = true;
- startX = e.clientX; startY = e.clientY;
- const rect = painel.getBoundingClientRect();
- startLeft = rect.left; startTop = rect.top;
- painel.style.right = 'auto';
- document.onmousemove = (moveEvent) => {
- if (!isDragging) return;
- painel.style.left = startLeft + moveEvent.clientX - startX + 'px';
- painel.style.top = startTop + moveEvent.clientY - startY + 'px';
- };
- document.onmouseup = () => {
- isDragging = false;
- document.onmousemove = null;
- document.onmouseup = null;
- };
- };
- const btnIniciar = document.getElementById('btn-iniciar');
- const btnFechar = document.getElementById('btn-fechar');
- const textarea = document.getElementById('texto-cpfs');
- const divStatus = document.getElementById('status-automacao');
- // Elementos da modal de fechamento
- const modalConfirmacao = document.getElementById('modal-confirmacao');
- const btnFecharSim = document.getElementById('btn-fechar-sim');
- const btnFecharNao = document.getElementById('btn-fechar-nao');
- // Divs de resultado em tempo real e títulos
- const divResultado = document.getElementById('resultado-automacao');
- const boxEntregues = document.getElementById('box-entregues');
- const boxRecusados = document.getElementById('box-recusados');
- const tituloEntregues = document.getElementById('titulo-entregues');
- const tituloRecusados = document.getElementById('titulo-recusados');
- const listaEntregues = document.getElementById('lista-entregues');
- const listaRecusados = document.getElementById('lista-recusados');
- // Controle de estado para Iniciar/Pausar
- let isRunning = false;
- let isPaused = false;
- // Aciona a div modal de fechamento
- btnFechar.onclick = () => {
- modalConfirmacao.style.display = 'flex';
- };
- btnFecharSim.onclick = () => painel.remove();
- btnFecharNao.onclick = () => {
- modalConfirmacao.style.display = 'none';
- };
- btnIniciar.onclick = async () => {
- // Se já estiver rodando, o botão funciona como PAUSAR / CONTINUAR
- if (isRunning) {
- isPaused = !isPaused;
- if (isPaused) {
- btnIniciar.innerText = '[ CONTINUAR ]';
- divStatus.innerText = divStatus.innerText + " (PAUSADO)";
- } else {
- btnIniciar.innerText = '[ PAUSAR ]';
- divStatus.innerText = divStatus.innerText.replace(" (PAUSADO)", "");
- }
- return;
- }
- const rawText = textarea.value;
- const listaItens = rawText.split('\n').map(c => c.trim()).filter(c => c.length > 0);
- if (listaItens.length === 0) return alert('Insira os dados.');
- isRunning = true;
- isPaused = false;
- btnIniciar.innerText = '[ PAUSAR ]';
- textarea.disabled = true;
- // Inicializa contadores
- const totalItens = listaItens.length;
- let qtdEntregues = 0;
- let qtdRecusados = 0;
- // Limpa resultados anteriores
- divResultado.style.display = 'block';
- tituloEntregues.innerText = `ENTREGUES: 0/${totalItens}`;
- tituloRecusados.innerText = `RECUSADOS: 0/${totalItens}`;
- listaEntregues.innerHTML = '';
- listaRecusados.innerHTML = '';
- boxEntregues.style.display = 'none';
- boxRecusados.style.display = 'none';
- for (let i = 0; i < listaItens.length; i++) {
- // Loop de espera caso o bot seja pausado
- while (isPaused) {
- await new Promise(resolve => setTimeout(resolve, 300));
- if (!document.getElementById('painel-automacao-tonny')) return;
- }
- const termo = listaItens[i];
- divStatus.innerText = `Consultando [${i + 1}/${totalItens}]: ${termo}`;
- const apenasNumeros = termo.replace(/\D/g, '');
- const isCpf = termo.includes('-') || apenasNumeros.length === 11;
- // anti-ghost antigo
- Array.from(document.querySelectorAll('button')).forEach(btn => {
- const txt = btn.innerText.toLowerCase();
- if (txt.includes('ver pedido') || txt === 'fechar') {
- // Sobe os níveis do HTML para pegar a caixa inteira e apagar
- let parent = btn.parentElement;
- for(let lvl = 0; lvl < 4; lvl++) {
- if (parent) parent = parent.parentElement;
- }
- if (parent) {
- parent.innerHTML = '';
- parent.style.display = 'none';
- }
- }
- });
- // Troca de abas se necessário
- const botoesNaTela = Array.from(document.querySelectorAll('button'));
- const btnCpf = botoesNaTela.find(b => b.innerText.includes('CPF'));
- const btnRastreio = botoesNaTela.find(b => b.innerText.includes('Código de rastreio'));
- if (isCpf && btnCpf) btnCpf.click();
- else if (!isCpf && btnRastreio) btnRastreio.click();
- await new Promise(resolve => setTimeout(resolve, 300)); // não mexer
- const input = document.getElementById('tracking-input');
- if (!input) {
- divStatus.innerText = "Erro: Input não encontrado.";
- break;
- }
- // Injeta o novo código
- const nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value").set;
- nativeInputValueSetter.call(input, termo);
- input.dispatchEvent(new Event('input', { bubbles: true }));
- // Clica em pesquisar
- const btnSubmit = document.querySelector('button[type="submit"]');
- if (btnSubmit) btnSubmit.click();
- // Tempo de busca original
- await new Promise(resolve => setTimeout(resolve, 7000)); // Mexer só se necessário
- // Procura o novo botão "Ver pedido" (se ele não existir, a tela continua limpa e o bot pula)
- const botoesAposBusca = Array.from(document.querySelectorAll('button'));
- const btnVerPedido = botoesAposBusca.find(b => b.innerText.toLowerCase().includes('ver pedido'));
- let textoParaAnalisar = "";
- if (btnVerPedido) {
- btnVerPedido.click();
- await new Promise(resolve => setTimeout(resolve, 1000)); // Aguarda abrir detalhes
- // Extrai o texto garantindo que é o novo carregamento
- textoParaAnalisar = document.body.innerText.toLowerCase();
- } else {
- // Se não achou o botão de ver pedido, a busca falhou ou não existe. O texto fica vazio.
- textoParaAnalisar = "";
- }
- // Puxa a data usando regex
- const regexDataHora = /em \d{2}\/\d{2}\/\d{4} às \d{2}:\d{2}/;
- const match = textoParaAnalisar.match(regexDataHora);
- const stringDataHora = match ? ` (${match[0]})` : '';
- // Monta a linha SEM o Link (HTML)
- const linhaResultado = `<span style="font-size: 11px;">- ${termo} ${stringDataHora}</span><br>`;
- // Verifica as palavras-chave apenas se houver um texto para analisar
- if (textoParaAnalisar !== "") {
- if (textoParaAnalisar.includes('entregue') || textoParaAnalisar.includes('o pacote foi assinado') || textoParaAnalisar.includes('assinado')) {
- qtdEntregues++;
- tituloEntregues.innerText = `ENTREGUES: ${qtdEntregues}/${totalItens}`;
- boxEntregues.style.display = 'block';
- listaEntregues.innerHTML += linhaResultado;
- } else if (textoParaAnalisar.includes('• recusado') || textoParaAnalisar.includes('foi recusado')) {
- qtdRecusados++;
- tituloRecusados.innerText = `RECUSADOS: ${qtdRecusados}/${totalItens}`;
- boxRecusados.style.display = 'block';
- listaRecusados.innerHTML += linhaResultado;
- }
- }
- // Rola a div de resultado
- divResultado.scrollTop = divResultado.scrollHeight;
- }
- // Restaura estados no final da execução
- divStatus.innerText = 'Status: Finalizado!';
- isRunning = false;
- btnIniciar.innerText = '[ INICIAR ]';
- textarea.disabled = false;
- };
- })();
Advertisement
Add Comment
Please, Sign In to add comment