GuiEnrik

Ofuscar Dados

Apr 22nd, 2026
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.   const SELETOR_PROFESSOR = 'body > ngb-offcanvas-panel > app-novo-registro > div.offcanvas-header.border-bottom.h-auto > div:nth-child(2) > div > div:nth-child(1) > div.flex-grow-1.ms-3.me-2 > h6';
  3.  
  4.   const NOME_PROFESSOR = 'PROF. FULANO DA SILVA';
  5.  
  6.   const primeirosNomes = [
  7.     'FULANO', 'SICRANO', 'BELTRANO',
  8.     'FULANA', 'SICRANA', 'BELTRANA',
  9.     'FULANITO', 'FULANITA',
  10.     'CICRANITO', 'SICRANITA',
  11.     'CISBELTRANO', 'CISBELTRANA'
  12.   ];
  13.  
  14.   const sobrenomes = [
  15.     'DA SILVA',
  16.     'DE SOUZA',
  17.     'DE TAL'
  18.   ];
  19.  
  20.   function gerarNomeAluno(i) {
  21.     const primeiro = primeirosNomes[i % primeirosNomes.length];
  22.     const sobrenome = sobrenomes[Math.floor(i / primeirosNomes.length) % sobrenomes.length];
  23.     return `${primeiro} ${sobrenome}`.toUpperCase();
  24.   }
  25.  
  26.   function gerarMatricula(i, tamanhoOriginal = 6) {
  27.     const base = 1234 + i;
  28.     return String(base).padStart(Math.max(4, tamanhoOriginal), '0');
  29.   }
  30.  
  31.   function texto(el) {
  32.     return (el?.textContent || '').trim();
  33.   }
  34.  
  35.   function substituirProfessor() {
  36.     const el = document.querySelector(SELETOR_PROFESSOR);
  37.     if (el) {
  38.       el.textContent = NOME_PROFESSOR;
  39.       console.log('Nome do professor alterado.');
  40.     } else {
  41.       console.warn('Elemento do nome do professor não encontrado.');
  42.     }
  43.   }
  44.  
  45.   function ofuscarTabelas() {
  46.     let contador = 0;
  47.  
  48.     document.querySelectorAll('table').forEach(table => {
  49.       const linhas = table.querySelectorAll('tr');
  50.  
  51.       linhas.forEach(tr => {
  52.         const tds = tr.querySelectorAll('td');
  53.         if (tds.length < 3) return;
  54.  
  55.         const col1 = tds[0];
  56.         const col2 = tds[1];
  57.         const col3 = tds[2];
  58.  
  59.         const v1 = texto(col1);
  60.         const v2 = texto(col2);
  61.         const v3 = texto(col3);
  62.  
  63.         const ehMatricula = /^\d{4,}$/.test(v1);
  64.         const ehNumeroSequencial = /^\d+$/.test(v2);
  65.         const ehNome = /[A-Za-zÀ-ÿ]{3,}/.test(v3);
  66.  
  67.         if (ehMatricula && ehNumeroSequencial && ehNome) {
  68.           col1.textContent = gerarMatricula(contador, v1.length);
  69.           col3.textContent = gerarNomeAluno(contador);
  70.           contador++;
  71.         }
  72.       });
  73.     });
  74.  
  75.     console.log(`Alunos ofuscados: ${contador}`);
  76.   }
  77.  
  78.   substituirProfessor();
  79.   ofuscarTabelas();
  80. })();
Advertisement
Add Comment
Please, Sign In to add comment