Skip to content

Instantly share code, notes, and snippets.

@nghiepdev
Last active March 30, 2025 23:20
Show Gist options
  • Save nghiepdev/e9df0c731012e2060b49b180000bbd98 to your computer and use it in GitHub Desktop.
Save nghiepdev/e9df0c731012e2060b49b180000bbd98 to your computer and use it in GitHub Desktop.
Unfollow Tiktok
function autoScrollToLastFollower() {
const lastFollower = document.querySelector(
'div[data-e2e="follow-info-popup"]>div:last-child>li:last-child'
);
if (lastFollower) {
lastFollower.scrollIntoView();
} else {
console.info('No follower found. Make sure you are on the following page and opening list of followers.');
}
}
function unfollowFirstMatchingUser() {
const targetText = 'Following';
const allButtons = Array.from(
document.querySelectorAll('button[data-e2e="follow-button"]')
);
const matchingButtons = allButtons.filter(
(button) => button.textContent.trim() === targetText
);
const firstButton = matchingButtons[0];
if (firstButton) {
firstButton.click();
console.info('Unfollow success!!!');
}
countRemainingFollowing();
}
function countRemainingFollowing() {
const followingButtons = Array.from(
document.querySelectorAll('button[data-e2e="follow-button"]')
).filter((button) => button.textContent.trim() === 'Following');
console.info(followingButtons.length);
}
setInterval(autoScrollToLastFollower, 3000);
setInterval(unfollowFirstMatchingUser, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment