Skip to content

Instantly share code, notes, and snippets.

@alejandrade
Last active April 21, 2024 11:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alejandrade/5f2c9bea835b4b80e3fd4532ff2736ad to your computer and use it in GitHub Desktop.
Save alejandrade/5f2c9bea835b4b80e3fd4532ff2736ad to your computer and use it in GitHub Desktop.
Automate TikTok Video Deletion Script
/*
A script to delete all videos from a Tittok account
Learn how to delete all TikTok videos programmatically with this JavaScript script.
This script triggers hover events, clicks "Delete" buttons, and automates the video deletion process.
1. go to your latest video and paste this entire script in the terminal.
2. wait until all videos are deleted one by one
This script will programatically click the delete button on your videos one by one.
*/
function triggerHoverEvent(element) {
const hoverEvent = new MouseEvent('mouseover', {
bubbles: true,
cancelable: true,
view: window,
});
element.dispatchEvent(hoverEvent);
}
function clickDeleteButtonInLI() {
const liElements = document.querySelectorAll('li[data-e2e="video-delete"]');
for (const liElement of liElements) {
const deleteButton = liElement.querySelector('button');
if (deleteButton && deleteButton.textContent.trim() === 'Delete') {
deleteButton.click();
setTimeout(() => {
const modalDeleteButton = document.querySelector('[data-e2e="video-modal-delete"]');
if (modalDeleteButton) {
modalDeleteButton.click();
}
}, 200); // Wait 200 milliseconds after clicking "Delete" button
return; // Exit the loop after the first successful click
}
}
}
function performVideoDeletion() {
const targetElement = document.querySelector('[data-e2e="video-setting"]');
if (targetElement) {
triggerHoverEvent(targetElement);
setTimeout(clickDeleteButtonInLI, 2000); // Adjust the initial delay as needed (2 seconds in this case)
setTimeout(() => {
performVideoDeletion(); // Recursively call the function after a 3-second delay
}, 3000); // Wait 3 seconds before performing the next operation
} else {
console.log("No more elements found. Stopping.");
}
}
// Start the process
performVideoDeletion();
@StarEren
Copy link

StarEren commented Feb 21, 2024

Thinking if this could be done for your own comments on other videos using comment history.

@evakatty777
Copy link

hi if I change the script a little can this work for removing all your repost ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment