-
-
Save shrayasr/8ba2f9f740dfdceb31834a0eb35cb4c2 to your computer and use it in GitHub Desktop.
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) |
Thanks
Thanks.
Also needed to include JQuery on the page: https://stackoverflow.com/questions/7474354/include-jquery-in-the-javascript-console
Thanks so much, this has been annoying me for ages.
Much faster:
//go to activity page first. click search as the activity list gets low.
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load
jQuery.noConflict();
function foo() {
var li = $(".list-item").not('.fadeOut')[0];
var delButton = $(li).find("button.js-activity-delete");
var confirmDelButton = $(li).find("button.delete-yes");
$(delButton).click();
setTimeout(function() {
$(confirmDelButton).click();
}, 100);
}
setInterval(foo, 500);
Thank you!
Thanks everybody!
Can someone explain to me how to actually run this script? (Im kindof a noob)
Can someone explain to me how to actually run this script? (Im kindof a noob)
Sure thing.
So you first have to open the javascript console of your browser. Here is a link for that.
And once you have done that, first paste in this code:
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load, then type (or see below for non wait option)
jQuery.noConflict();
This will ensure that you have jQuery on the page which is a requirement for you to run this script.
Once that is done, you can copy the script in the gist above, paste it in the console, hit enter and it will start deleting all your garmin connect activities.
Edit: You can also use the script that @tony-gutierrez has commented to go faster
Awesome, that just saved me a ton of time! Thank you all.
really great, new on Garmin connect, I bought a used device and it import all the activities from the previous owner. Thanks !
This is really great! Is there any similar way to bulk delete all the body weight (or any measurement) entries from Garmin Connect.
I happened to import 8 years of weight data into GConnect from FitBit, but entered them as kg instead of pound. :(( Now, I have 700+ entries to delete.
Yes but you are likely going to have to make the program yourself (easier than it might sound). You can use a macro automation program where you record yourself completing the task (deleting a single weight) and then the program can replay this over and over. Pulover’s Macro Creator should work for this https://www.macrocreator.com/
Also if you are familiar with python you can use the pyautogui library to automate tasks.
Thx a lot. This is incredible time saver
Use the following code to delete courses. If automaticly importing from Strava there can be a lot of old courses/routes.
//go to courses page first. click search as the activity list gets low.
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// ... give time for script to load
jQuery.noConflict();
function foo() {
console.log("foo - start")
$("button.search-button").click()
setTimeout(function() {
var list = $(".quick-action")
console.log("List length:", list.length)
if (list.length > 2) {
var li = $(list)[list.length - 1]
var delButton = $(li).find("a.icon-trash")[0]
console.log(delButton)
delButton.click()
setTimeout(function() {
var confirmDelButton = $(".js-saveBtn")[0]
console.log(confirmDelButton)
confirmDelButton.click()
console.log("foo - end")
}, 2000)
}
}, 100)
}
setInterval(foo, 2500)
Extremely helpful, thanks!
If I add new activities will the code keep executing forever? If so, how can I stop it?
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);
})();
Nice!