An automated tool to delete tweets, retweets, and replies from your Twitter/X account.
- Bulk Deletion: Automatically deletes tweets, retweets, and replies
- Performance Optimized: Uses direct JavaScript execution for faster interaction
- Configurable: Set how many posts to delete and other parameters
- Retry Logic: Handles network issues and UI inconsistencies
- Timing Analytics: Measures performance at each step
- Comprehensive Handling: Works with regular tweets, retweets, and replies
- Python 3.6+
- Selenium WebDriver
- Chrome Browser
- ChromeDriver compatible with your Chrome version
-
Clone this repository:
git clone https://github.com/yourusername/twitter-x-post-cleaner.git cd twitter-x-post-cleaner -
Install the required dependencies:
pip install selenium -
Download the appropriate ChromeDriver for your Chrome version and operating system.
-
Update the
chrome_driver_pathin the script to point to your ChromeDriver location.
-
Edit
delete_tweets.pyto add your Twitter/X username and password:TWITTER_USERNAME = "your_username" TWITTER_PASSWORD = "your_password"
-
Configure the script settings if needed:
HEADLESS = False # Set to True to run without visible browser SLEEP_BETWEEN_ACTIONS = 1 # Seconds to wait between actions MAX_TWEETS_TO_DELETE = 100 # Maximum number of tweets to delete
-
Run the script:
python delete_tweets.py
Set HEADLESS = True to run the browser in background mode without displaying a UI. This is useful for servers or automated runs.
Adjust SLEEP_BETWEEN_ACTIONS to control how long the script waits between actions. Lower values make it faster but may cause errors if Twitter's interface doesn't load fast enough.
Set MAX_TWEETS_TO_DELETE to limit how many posts will be deleted in a single run.
- Make sure your username and password are correct
- If you have 2FA enabled, you may need to manually complete the authentication
- Twitter may block automated logins; try running with
HEADLESS = Falseto see what's happening
- The script has multiple fallbacks for finding elements, but Twitter's UI changes frequently
- Check the console output for timing information to see where it's failing
- Consider increasing
SLEEP_BETWEEN_ACTIONSif pages aren't loading fast enough
- The script attempts to remove overlays and popups that might block clicks
- If you see "click intercepted" errors, try running with the UI visible to see what's happening
This script contains your Twitter/X credentials in plain text. Never share the configured script or upload it to public repositories. This README assumes you're forking the template repository and configuring it privately.
The script reports timing for each action. If you see consistently slow steps, consider:
- Increasing your internet connection speed
- Reducing
SLEEP_BETWEEN_ACTIONSif your computer is fast - Using a more powerful computer with more RAM
- Running in headless mode to reduce UI rendering overhead
Use this script at your own risk. Automated interaction with Twitter/X may violate their Terms of Service. The script attempts to mimic human behavior, but Twitter may still detect and restrict automated activity.
This project is licensed under the MIT License - see the LICENSE file for details.