Created
July 24, 2025 17:02
-
-
Save angelmartz/408533e97fef5f9384a2c8f5624093c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (async () => { | |
| const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
| const obtenerDiasValidos = (excluidos) => { | |
| return Array.from(document.querySelectorAll('#calendario td[data-handler="selectDay"] a')) | |
| .filter(a => !a.classList.contains('diaCapturado') && !a.classList.contains('diaInhabil')) | |
| .filter(a => !excluidos.includes(a.textContent.trim())); // no repetir | |
| }; | |
| const esperarFinDeCaptura = async () => { | |
| let intentos = 0; | |
| while (intentos < 20) { | |
| const capturaDia = document.getElementById("Id_CapturaDia"); | |
| if (capturaDia && capturaDia.value === "0") break; | |
| await delay(500); | |
| intentos++; | |
| } | |
| }; | |
| const diasProcesados = []; | |
| while (true) { | |
| const diasPendientes = obtenerDiasValidos(diasProcesados); | |
| if (diasPendientes.length === 0) break; | |
| const dia = diasPendientes[0]; | |
| const numeroDia = dia.textContent.trim(); | |
| dia.click(); | |
| console.log(`✅ Día ${numeroDia} seleccionado`); | |
| await delay(600); | |
| const actividadSelect = document.getElementById("cmbActividades"); | |
| if (actividadSelect) { | |
| actividadSelect.value = "1221589"; | |
| actividadSelect.dispatchEvent(new Event("change")); | |
| } | |
| const horasSelect = document.getElementById("HorasCapturadas"); | |
| if (horasSelect) { | |
| horasSelect.value = "8"; | |
| horasSelect.dispatchEvent(new Event("change")); | |
| } | |
| const btnOk = document.getElementById("btnOk"); | |
| if (btnOk) { | |
| btnOk.click(); | |
| console.log(`📤 Captura enviada para el día ${numeroDia}`); | |
| } | |
| diasProcesados.push(numeroDia); | |
| await esperarFinDeCaptura(); | |
| await delay(300); // tiempo adicional para permitir la actualización de DOM | |
| } | |
| console.log("✅ Todos los días válidos han sido capturados sin duplicados."); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment