-
Notifications
You must be signed in to change notification settings - Fork 1
/
GARMIN_Bulk_Workout_Delete
32 lines (25 loc) · 1.16 KB
/
GARMIN_Bulk_Workout_Delete
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// CODE TO BE EXECUTED WITHIN BROWSER DEVELOPMENT TOOLS - CONSOLE
// Besure to be already within the Garmin Connect, Workouts page, before executing this
// Inspired by https://blog.trainerday.com/garmin-connect-bulk-delete-workouts-from-your-training-library-25b2991ba2e6
function deleteWorkouts() {
const deleteWorkoutElements = document.querySelectorAll('.delete-workout');
if (deleteWorkoutElements.length === 0) {
console.log('No more "delete-workout" elements found.');
return;
}
// Click the first "delete-workout" element to open the pop-up
deleteWorkoutElements[0].click();
setTimeout(() => {
const deleteButton = document.querySelector('a.btn.btn-primary.js-saveBtn.btn-danger');
if (deleteButton) {
deleteButton.click();
} else {
console.log('Delete button not found.');
}
setTimeout(() => {
deleteWorkouts(); // Recursively call to delete the next workout
}, 1000); // Adjust the delay (in milliseconds) as needed
}, 1000); // Adjust the delay (in milliseconds) as needed
}
// Start the process by calling the function
deleteWorkouts();