Skip to content

Instantly share code, notes, and snippets.

@shrayasr
Created March 28, 2018 06:03
Show Gist options
  • Save shrayasr/8ba2f9f740dfdceb31834a0eb35cb4c2 to your computer and use it in GitHub Desktop.
Save shrayasr/8ba2f9f740dfdceb31834a0eb35cb4c2 to your computer and use it in GitHub Desktop.
Bulk delete activities in Garmin Connect
function foo() {
console.log("foo - start")
$("button.search-button").click()
setTimeout(function() {
var li = $(".list-item")[0]
var delButton = $(li).find("button.js-activity-delete")
var confirmDelButton = $(li).find("button.delete-yes")
console.log(delButton, confirmDelButton)
$(delButton).click()
setTimeout(function() {
$(confirmDelButton).click()
console.log("foo - end")
}, 100)
}, 2000)
}
setInterval(foo, 3000)
@lizcue
Copy link

lizcue commented Dec 28, 2023

Extremely helpful, thanks!
If I add new activities will the code keep executing forever? If so, how can I stop it?

@lordmat0
Copy link

lordmat0 commented Dec 29, 2023 via email

@CaitW
Copy link

CaitW commented Apr 23, 2025

I wrote my own script for this recently. Go to https://connect.garmin.com/modern/courses then paste this into your console:

(() => {
  // Every 1 second, click the little trash can icon next to a course
  setInterval(() => {
    document.querySelector("button[aria-label='Delete']").click();

    // Wait 500ms for the modal to open, then click the delete button
    setTimeout(() => {
      // This delete button doesn't have a good class name, so find all the
      // buttons, then find one with the text "Delete"
      const buttons = document.querySelectorAll("button");
      const deleteButton = Array.from(buttons).find((button) =>
        button.textContent.includes("Delete"),
      );
      deleteButton.click();
    }, 500);
  }, 1000);
})();

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