Skip to content

Instantly share code, notes, and snippets.

@humitos
Last active November 19, 2022 09:39
Show Gist options
  • Save humitos/7185ecf15e4b603010a27007ace13b6e to your computer and use it in GitHub Desktop.
Save humitos/7185ecf15e4b603010a27007ace13b6e to your computer and use it in GitHub Desktop.
Download a URL workout from Sport Tracker as GPX
// Download file from https://www.sports-tracker.com/
// Example: https://www.sports-tracker.com/workout/jaumenarbona/61b508ae59ba772af9278c87
//
// Based on:
// - https://ivanderevianko.com/2016/04/export-all-workouts-from-sports-tracker
// - https://gist.github.com/KonstantinosSykas/dfe4c5e392e299ab9341d6e16299454f
//
//
// Instructions:
// 1. Open the URL of the workaround you want to export
// 2. Open the developer console
// 3. Paste this script there and run it
// 4. Click on the URL shown in the console's output
var id = href.substr(href.lastIndexOf('/') + 1, 24);
var key = "sessionkey=";
var valueStartIndex = document.cookie.indexOf(key) + key.length;
var token = document.cookie.substr(valueStartIndex, 32);
var activities = ["Walking", "Running", "Cycling", "CrossCountrySkiing", "Other1", "Other2", "Other3", "Other4", "Other5", "Other6", "MountainBiking", "Hiking", "RollerSkating", "AlpineSkiing", "Paddling", "Rowing", "Golf", "Indoor", "Parkour", "BallGames", "OutdoorGym", "PoolSwimming", "TrailRunning", "Gym", "NordicWalking", "HorsebackRiding", "Motorsports", "Skateboarding", "WaterSports", "Climbing", "Snowboarding", "SkiTouring", "FitnessClass", "Soccer", "Tennis", "Basketball", "Badminton", "Baseball", "Volleyball", "AmericanFootball", "TableTennis", "RacquetBall", "Squash", "Floorball", "Handball", "Softball", "Bowling", "Cricket", "Rugby", "IceSkating", "IceHockey", "Yoga", "IndoorCycling", "Treadmill", "Crossfit", "Crosstrainer", "RollerSkiing", "IndoorRowing", "Stretching", "TrackAndField", "Orienteering", "StandupPaddling", "MartialArts", "Kettlebell", "Dancing", "SnowShoeing", "Frisbee", "Futsal", "Multisport", "Aerobics", "Trekking", "Sailing", "Kayaking", "CircuitTraining", "Triathlon", "Undefined1", "Cheerleading", "Boxing", "ScubaDiving", "FreeDiving", "AdventureRacing", "Gymnastics", "Canoeing", "Mountaineering", "TelemarkSkiing", "OpenwaterSwimming", "Windsurfing", "KitesurfingKiting", "Paragliding", "Undefined2", "Snorkeling", "Surfing", "Swimrun", "Duathlon", "Aquathlon", "ObstacleRacing", "Fishing", "Hunting"];
// TODO: auto-select the activity type based on page content
var activity_type = "RollerSkating";
var activity_date = document.getElementsByClassName("workout-date-text")[0];
var activity_date_month = activity_date.textContent.substr(0, 3);
var activity_date_day = activity_date.textContent.substr(4, activity_date.textContent.indexOf(',') - 4);
var activity_date_year = activity_date.textContent.substr(activity_date.textContent.indexOf(',') + 2, 4);
switch(activity_date_month) {
case 'Jan':
activity_month = '01';
break;
case 'Feb':
activity_month = '02';
break;
case 'Mar':
activity_month = '03';
break;
case 'Apr':
activity_month = '04';
break;
case 'May':
activity_month = '05';
break;
case 'Jun':
activity_month = '06';
break;
case 'Jul':
activity_month = '07';
break;
case 'Aug':
activity_month = '08';
break;
case 'Sep':
activity_month = '09';
break;
case 'Oct':
activity_month = '10';
break;
case 'Nov':
activity_month = '11';
break;
case 'Dec':
activity_month = '12';
break;
}
var url = 'http://api.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token;
var filename = 'SportsTracker-' + activity_type + '-' + activity_date + '-' + id + '.gpx';
console.log("Download the follownig URL by clicking on it: " + url);
@DutchWorkshop
Copy link

So far gets me the error message:

VM487:1 Uncaught ReferenceError: href is not defined at :1:10 (anonymous) @ VM487:1

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