Skip to content

Instantly share code, notes, and snippets.

@alejandrade
Last active July 8, 2024 06:59
Show Gist options
  • 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();
@MajidQureshi98
Copy link

How to us this file

@alejandrade
Copy link
Author

How to us this file

Read the comments

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