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);