Last active
July 8, 2024 06:59
-
-
Save alejandrade/5f2c9bea835b4b80e3fd4532ff2736ad to your computer and use it in GitHub Desktop.
Automate TikTok Video Deletion Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the comments