-
-
Save cjaSource/1eb613da69df331273c9b44f2ec0101d to your computer and use it in GitHub Desktop.
Download all workouts from sports-tracker
This file contains 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
const key = "sessionkey="; | |
const valueStartIndex = document.cookie.indexOf(key) + key.length; | |
const token = document.cookie.substring(valueStartIndex, document.cookie.indexOf(';', valueStartIndex)); | |
const activities = {0:"walk",1:"run",2:"ride",11:"hike",13:"alpineski",14:"rowing",15:"rowing"}; | |
function downloadOne(item) { | |
var item = items[iGlobal]; | |
const href = item.href; | |
const id = href.substr(href.lastIndexOf('/') + 1, 24); | |
const url = 'https://api.sports-tracker.com/apiserver/v1/workout/exportGpx/' + id + '?token=' + token; | |
console.log(url); | |
window.open(url); | |
++iGlobal; | |
// const activityId = item.querySelector(".activity-icon").getAttribute('activity-icon'); | |
// const filename = `id--${id}--activity--${activities[activityId]}--title--${item.querySelector(".description").title.replace('/',',')}--file.gpx`; | |
// console.log(`mkdir "${id}"`); | |
// console.log(`curl -o "${id}/${filename}" "${url}";`); | |
// downloadImages(id); | |
} | |
// async function downloadImages(id) { | |
// const imagesUrl = 'https://api.sports-tracker.com/apiserver/v1/images/workout/' + id + '?token=' + token; | |
// const imageApiResponse = await fetch(imagesUrl); | |
// const images = (await imageApiResponse.json()).payload; | |
// for (let i = 0; i < images.length; i++) { | |
// let image = images[i]; | |
// let filename = `${id}-${image.key}-${image.location.x}-${image.location.y}-${image.timestamp}.jpg`; | |
// let url = `https://api.sports-tracker.com/apiserver/v1/image/scale/${image.key}.jpg?width=${image.width}&height=${image.height}`; | |
// console.log(`curl -o "${id}/${filename}" "${url}";`); | |
// } | |
// } | |
function loopThroughItems() { | |
setInterval(downloadOne, 2000); | |
} | |
const items = document.querySelectorAll("ul.diary-list__workouts li a"); | |
var iGlobal = 0; | |
document.body.innerHtml = ''; | |
loopThroughItems(items); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Works as of Aug 2023