Last active
October 20, 2021 04:22
-
-
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.
This file contains hidden or 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
// 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