Created
January 1, 2025 19:42
-
-
Save palaueb/cdbc6202b0e84887c4d883186dc2bcc6 to your computer and use it in GitHub Desktop.
AUTOMATIC UNFOLLOWER
This file contains 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
function startProcess() { | |
console.log('inici'); | |
// Primer element: click al botó de "unfollow" | |
const unfollowButton = document.querySelector('button[data-testid$="unfollow"]'); | |
console.log(unfollowButton); | |
if (unfollowButton) { | |
unfollowButton.click(); | |
// Espera un temps aleatori entre 800 ms i 1200 ms i clicka al segon element | |
const randomDelay = Math.floor(Math.random() * (120 - 80 + 1)) + 80; | |
console.log('waiting:', randomDelay); | |
setTimeout(() => { | |
const confirmButton = document.querySelector('[data-testid="confirmationSheetConfirm"]'); | |
console.log(confirmButton); | |
if (confirmButton) { | |
confirmButton.click(); | |
let element=unfollowButton; | |
while (element && element.getAttribute("data-testid") !== "cellInnerDiv") { | |
element = element.parentElement; | |
} | |
// `element` serà el node que conté l'atribut o `null` si no es troba cap. | |
if (element) { | |
element.remove(); | |
} else { | |
console.log("No s'ha trobat cap element amb data-testid='cellInnerDiv'."); | |
} | |
} else { | |
console.error("No s'ha trobat el botó de confirmació."); | |
} | |
}, randomDelay); | |
} else { | |
console.error("No s'ha trobat el botó de 'unfollow'."); | |
} | |
} | |
// Inicia el procés amb un interval aleatori | |
setInterval(() => { | |
startProcess(); | |
}, Math.floor(Math.random() * (1200 - 800 + 1)) + 800); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment