Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (() => {
- 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';
- const NOME_PROFESSOR = 'PROF. FULANO DA SILVA';
- const primeirosNomes = [
- 'FULANO', 'SICRANO', 'BELTRANO',
- 'FULANA', 'SICRANA', 'BELTRANA',
- 'FULANITO', 'FULANITA',
- 'CICRANITO', 'SICRANITA',
- 'CISBELTRANO', 'CISBELTRANA'
- ];
- const sobrenomes = [
- 'DA SILVA',
- 'DE SOUZA',
- 'DE TAL'
- ];
- function gerarNomeAluno(i) {
- const primeiro = primeirosNomes[i % primeirosNomes.length];
- const sobrenome = sobrenomes[Math.floor(i / primeirosNomes.length) % sobrenomes.length];
- return `${primeiro} ${sobrenome}`.toUpperCase();
- }
- function gerarMatricula(i, tamanhoOriginal = 6) {
- const base = 1234 + i;
- return String(base).padStart(Math.max(4, tamanhoOriginal), '0');
- }
- function texto(el) {
- return (el?.textContent || '').trim();
- }
- function substituirProfessor() {
- const el = document.querySelector(SELETOR_PROFESSOR);
- if (el) {
- el.textContent = NOME_PROFESSOR;
- console.log('Nome do professor alterado.');
- } else {
- console.warn('Elemento do nome do professor não encontrado.');
- }
- }
- function ofuscarTabelas() {
- let contador = 0;
- document.querySelectorAll('table').forEach(table => {
- const linhas = table.querySelectorAll('tr');
- linhas.forEach(tr => {
- const tds = tr.querySelectorAll('td');
- if (tds.length < 3) return;
- const col1 = tds[0];
- const col2 = tds[1];
- const col3 = tds[2];
- const v1 = texto(col1);
- const v2 = texto(col2);
- const v3 = texto(col3);
- const ehMatricula = /^\d{4,}$/.test(v1);
- const ehNumeroSequencial = /^\d+$/.test(v2);
- const ehNome = /[A-Za-zÀ-ÿ]{3,}/.test(v3);
- if (ehMatricula && ehNumeroSequencial && ehNome) {
- col1.textContent = gerarMatricula(contador, v1.length);
- col3.textContent = gerarNomeAluno(contador);
- contador++;
- }
- });
- });
- console.log(`Alunos ofuscados: ${contador}`);
- }
- substituirProfessor();
- ofuscarTabelas();
- })();
Advertisement
Add Comment
Please, Sign In to add comment