Multiply several distance fields to display new number - javascript?

I have a Garmin smartwatch and went for a 14km run on a treadmill and the final distance shown in my data file was 12.17km even though I completed a longer distance.

I’m able to modify the TCX file after exporting from my Garmin profile - is there a javascript code or script than can change the <DistanceMeters> field to a higher number? The figure needs to be multiplied by 1.152, so the figure highlighted below would change from 50.450 to 58.1184

I would be forever grateful if someone is able to help or assist me, I am a novice when it comes to javascript or any coding and I have over 650 distance fields to alter which would take a considerable amount of time if I was to do it manually.

Thanks for your time! :smile:

Regards, Shaun (sticks1977)

28%20pm

Hi,

I am beginner so my code is certainly not the cleanest we can find but inserting this code should solve your problem :

<script>
  for(let i=0; i<document.getElementsByTagName("DistanceMeters").length; i++){
    document.getElementsByTagName("DistanceMeters")[i].innerHTML = 1.152 * parseFloat(document.getElementsByTagName("DistanceMeters")[i].innerHTML);
  }
</script>

Hoping this will help you :slight_smile:
Have nice runs

appreciate your reply Meditsh :smile:

How do I go about inserting this code? I am on a Mac but have access to a PC via a remote desktop/virtual machine. I attempted to add this code into ‘Script Editor’ on the Mac but had no luck when I tried to run the script.

You’re welcome :slight_smile:

I am sorry but I can’t help you as I don’t really understand the point of your research. Also because I never used a Garmin Smartwatch or a TCX file.
If you had a HTML file I would suggest to add my code between the head tag and then open it with your browser, the datas would be updated (only the datas displayed, not the datas stored).

What is your goal ? Do you understand that the TCX file is a datas base ? You can possibly edit it to stock or display different datas, but it won’t alter the way your smartwatch will do its future calculations (for the little that I know, don’t take it as a truth). In this case I would suggest to look for settings menu or profile menu and edit your step length.