Skip to content

Instantly share code, notes, and snippets.

@itsdarrylnorris
Last active October 20, 2021 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsdarrylnorris/d766940e5d16a8a359fcf44603a77639 to your computer and use it in GitHub Desktop.
Save itsdarrylnorris/d766940e5d16a8a359fcf44603a77639 to your computer and use it in GitHub Desktop.
Updates Strava Activities from Run to Walk. This is very helpful when importing data from the Apple health app.
// Go to My Activities page -> https://www.strava.com/athlete/training
// Paste this into the browser console.
// This should update activities in this page.
// This script does not support pagination, if you want to activities in other pages, go to next page and paste in the console
var typeFrom = "Run";
var typeTo = "Walk";
document
.querySelectorAll(".training-activity-row .col-type")
.forEach(function (type, index) {
if (type.innerText === typeFrom) {
// Opening the edit click
document
.querySelectorAll(".training-activity-row .quick-edit")
[index].click();
// Updating the title
document.querySelectorAll('.edit-col input[name="name"]')[index].value =
document
.querySelectorAll('.edit-col input[name="name"]')
[index].value.replace(typeFrom, typeTo);
// Updating dropdown.
document.querySelectorAll('.edit-col select[name="type"]')[index].value =
typeTo;
document
.querySelectorAll('.edit-col select[name="type"]')
[index].dispatchEvent(new Event("change"));
}
});
// Saving all items
document
.querySelectorAll(".edit-actions button.btn-sm")
.forEach(function (editLink) {
editLink.click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment