Last active
November 25, 2024 11:21
-
-
Save j0rd1s3rr4n0/14da4e84ad324ac007c7edf205df3112 to your computer and use it in GitHub Desktop.
Snyk Project Clean
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
// | |
// URL: https://app.snyk.io/org/<USERNAME>/projects | |
// Author : https:github.com/j0rd1s3rr4n0 | |
// | |
async function deleteProjects() { | |
const projectsContainer = document.querySelector( | |
"#core > div > div > main > div.app-page.projects > div > div > div.projects-target-list__content" | |
); | |
if (!projectsContainer) { | |
console.error("No se encontró el contenedor de proyectos."); | |
return; | |
} | |
const projects = projectsContainer.childNodes; | |
for (let x of projects) { | |
try { | |
// Extraer el nombre del repositorio | |
const reponame = x.childNodes[0].childNodes[1].childNodes[1].childNodes[1].childNodes[0].childNodes[2].innerText; | |
console.log(`Procesando proyecto: ${reponame}`); | |
// Pausa antes de interactuar | |
await new Promise(r => setTimeout(r, 800)); | |
// Click en Options | |
x.childNodes[0].childNodes[2].childNodes[2].childNodes[1].click(); | |
// Pausa después del clic | |
await new Promise(r => setTimeout(r, 100)); | |
// Click en Delete | |
x.childNodes[0].childNodes[2].childNodes[2].childNodes[3].childNodes[0].childNodes[1].childNodes[1].childNodes[5].click(); | |
// Pausa antes de confirmar | |
await new Promise(r => setTimeout(r, 100)); | |
// Ingresar el nombre del repositorio en el cuadro de confirmación | |
document.querySelector("body > div.dialog").childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[1].childNodes[2].childNodes[3].childNodes[1].childNodes[1].childNodes[0].value = reponame | |
// Pausa antes de confirmar eliminación | |
await new Promise(r => setTimeout(r, 800)); | |
// Confirmar eliminación | |
const confirmButton = document.querySelector("body > div.dialog").childNodes[0].childNodes[0].childNodes[0].childNodes[1].childNodes[1].childNodes[3].childNodes[1]; | |
confirmButton.removeAttribute('disabled'); | |
confirmButton.click(); | |
} catch (error) { | |
console.error(`Error al procesar el proyecto: ${error.message}`); | |
} | |
} | |
} | |
deleteProjects(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment