Skip to content

Instantly share code, notes, and snippets.

@RaeesD
Forked from anonymous/sports-tracker-download.js
Last active February 10, 2019 08:59
Show Gist options
  • Select an option

  • Save RaeesD/00659582cd5a42c83638e7e0291efb1d to your computer and use it in GitHub Desktop.

Select an option

Save RaeesD/00659582cd5a42c83638e7e0291efb1d to your computer and use it in GitHub Desktop.

Revisions

  1. RaeesD revised this gist Feb 10, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions sports-tracker-download.js
    Original file line number Diff line number Diff line change
    @@ -28,9 +28,9 @@ var token = document.cookie.substring(valueStartIndex, document.cookie.indexOf('
    function downloadOne(item) {
    var href = item.href;
    var id = href.substr(href.lastIndexOf('/') + 1, 24);
    var url = 'http://www.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token;
    var url = 'https://www.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token;
    var filename = 'SportsTracker-' + id + '.gpx';
    console.log('curl -o ' + filename + ' "' + url + '";sleep 2');
    console.log('Invoke-WebRequest -Uri ' + ' "' + url + '" -OutFile "' + filename + '"');
    }

    function loopThroughItems(items)
  2. @invalid-email-address Anonymous created this gist Dec 9, 2016.
    49 changes: 49 additions & 0 deletions sports-tracker-download.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,49 @@
    // based entirely on this blog post:
    // http://druss.co/2016/04/export-all-workouts-from-sports-tracker/
    // unfortunately the original script no longer works, moslty because jQuery is
    // no longer available on sports-tracker pages.
    //
    // I've compiled the changes proposed in the comments in the script below.

    // to use the script, login to your sports-tracker account
    // change URL to http://www.sports-tracker.com/diary/workout-list
    // open browser console (Cmd-Shift-I)
    // paste the script, hit enter - it'll run and print something like this to the cosole:
    // curl -o SportsTracker-<..id..>.gpx "http://www.sports-tracker.com/apiserver....."

    // right-click on the colsole and save the contents to a file, call it download-all-workouts.sh
    // open terminal, change to the directory where you saved the contents of the console
    // edit the file - remove the javascript at the beginning of the file leaving only curl commands

    // fix permissions:
    // $>chmod +x download-all-workouts.sh

    // run the script:
    // $>./download-all-workouts.sh

    var key = "sessionkey=";
    var valueStartIndex = document.cookie.indexOf(key) + key.length;
    var token = document.cookie.substring(valueStartIndex, document.cookie.indexOf(';', valueStartIndex));

    function downloadOne(item) {
    var href = item.href;
    var id = href.substr(href.lastIndexOf('/') + 1, 24);
    var url = 'http://www.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token;
    var filename = 'SportsTracker-' + id + '.gpx';
    console.log('curl -o ' + filename + ' "' + url + '";sleep 2');
    }

    function loopThroughItems(items)
    {
    var i = 0;
    for (i = 0; i < items.length; i++) {
    downloadOne(items[i]);

    }

    }

    var items = document.querySelectorAll("ul.diary-list__workouts li a");
    document.body.innerHtml = '';
    loopThroughItems(items);