Skip to content

Instantly share code, notes, and snippets.

@BarkBarklington
Forked from nghiepdev/unfollow-tiktok.js
Created March 30, 2025 23:20
Show Gist options
  • Select an option

  • Save BarkBarklington/375b96e7754797f281e544df951f988b to your computer and use it in GitHub Desktop.

Select an option

Save BarkBarklington/375b96e7754797f281e544df951f988b 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