Skip to content

Instantly share code, notes, and snippets.

@palaueb
Created January 1, 2025 19:42
Show Gist options
  • Save palaueb/cdbc6202b0e84887c4d883186dc2bcc6 to your computer and use it in GitHub Desktop.
Save palaueb/cdbc6202b0e84887c4d883186dc2bcc6 to your computer and use it in GitHub Desktop.
AUTOMATIC UNFOLLOWER
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