Javascript to inject clickable link to upload Zwift activities to Cycling Analytics.
/* | |
VERSION 2 : run this bookmarklet per activity. | |
Blog post here: https://far-oeuf.com/cycling/2020-03-25-zwift-to-cycling-analytics | |
General instructions for bookmarklets and CA here: https://www.cyclinganalytics.com/blog/2018/10/upload-rides-from-zwift | |
Though somethings not working with the generated code, so go here to actually create the bookmarklet code: https://bookmarklets.org/maker/ | |
(remember to replace REPLACE_THIS_WITH_TOKEN with your token) | |
Go to your Zwift feed: https://zwift.com/feed | |
Select the activity you want to upload, then click on the Setting/Detail icon (round gear to the right of the ride title) | |
Now, run that bookmarklet. A 'SEND TO CA' button should appear. Click and upload. | |
Done. | |
version history: | |
24-03-2020: initial version. | |
25-03-2020: fixed 'SEND TO CA' button css, to make it look like the other buttons. | |
*/ | |
// ----- USE EVERYTHING BELOW THIS LINE (not including this line) ----- | |
$('.send-to-ca').remove(); // remove previous collateral | |
download_anchor = $("#activityFitFile"); // this is the S3 url to the activity fitfile | |
if (download_anchor) { | |
ca_title = "Zwift: " + $("#activityTitle").val(); | |
ca_json = {url: download_anchor.attr('href'),title: ca_title}; | |
ca_btn = $('<div class="ml-3 button border__radius__responsive--small button--bordered send-to-ca">SEND TO CA</div>').click(function() { | |
fetch('https://www.cyclinganalytics.com/api/me/upload', | |
{method: 'POST', headers: {'Authorization': 'Bearer REPLACE_THIS_WITH_TOKEN', 'Content-Type': 'application/json'}, | |
body: JSON.stringify(ca_json)}).then(function() { | |
ca_btn.html($('<i class="fa fa-check"></i>')); | |
}).catch(function() { | |
ca_btn.html($('<i class="fa fa-times"></i>')); | |
}); | |
}); | |
ca_btn.insertAfter(download_anchor); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment