Created
May 2, 2023 10:42
-
-
Save maikelthedev/82a5f4582b4ef01d99c2581d674aa5d0 to your computer and use it in GitHub Desktop.
Mass toot eraser
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
#!/bin/bash | |
# Replace the following variables with your actual values | |
INSTANCE_URL="https://vmst.io" # This is just an axample | |
ACCESS_TOKEN="asdasdas" # Get it from /settings/applications in your Mastodon instance. | |
USER_ID="12312312312" # Find your own ID with https://INSTANCE/api/v1/accounts/verify_credentials | jq '.id' | |
# Get the first page of your statuses | |
STATUSES=$(curl -s -H "Authorization: Bearer $ACCESS_TOKEN" "$INSTANCE_URL/api/v1/accounts/$USER_ID/statuses") | |
# Loop until there are no more statuses | |
while [ -n "$STATUSES" ]; do | |
# Extract the status IDs from the JSON array | |
IDS=$(echo $STATUSES | jq -r '.[].id') | |
# Loop through each status ID | |
for ID in $IDS; do | |
# Delete the status by ID | |
DELETION=$(curl -s -X DELETE "$INSTANCE_URL/api/v1/statuses/$ID" -H "Authorization: Bearer $ACCESS_TOKEN") | |
echo $DELETION | jq '.text' | |
# Stop for 60 second | |
echo "Pausing 60 seconds" | |
sleep 60 | |
# Print a message | |
echo "Deleted status $ID" | |
done | |
# Get the next page of your statuses using the last status ID as max_id | |
STATUSES=$(curl "$INSTANCE_URL/api/v1/accounts/$USER_ID/statuses?max_id=$ID" -H "Authorization: Bearer $ACCESS_TOKEN") | |
echo "Pausing before getting the next statuses" | |
sleep 1 | |
done | |
# Print a final message | |
echo "All statuses deleted" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment