Guest User

gc-rhr

a guest
Mar 18th, 2021
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. function getGCRecoveryHR() {
  2.     // get sleep data from garmin connect
  3.     let loc = window.location.href
  4.  
  5.     let connectURL = "https://connect.garmin.com/modern/activity/";
  6.     if (loc.indexOf(connectURL) != 0 || typeof jQuery === "undefined") {
  7.         alert(
  8. `You must be logged into Garmin Connect to run this script.
  9.  
  10. Your current tab must also be a Garmin Connect activity page with
  11. URL starting with: ${connectURL}`);
  12.         return;
  13.     }
  14.  
  15.     // Garmin Connect uses jQuery, so it's available for this script
  16.     const activityId = loc.replace(connectURL, "");
  17.  
  18.     jQuery.getJSON(
  19.         `https://connect.garmin.com/modern/proxy/activity-service/activity/${activityId}`,
  20.         function(response) {
  21.             if (response.summaryDTO.recoveryHeartRate === undefined) {
  22.                 alert("No recovery HR saved for this activity")
  23.             } else {
  24.                 alert(`❤ Recovery HR: ${response.summaryDTO.recoveryHeartRate} bpm`);
  25.             }
  26.         }
  27.     ).fail(function() {
  28.         alert("Failed to get activity data 😔");
  29.     })
  30. }
  31.  
  32. getGCRecoveryHR()
Advertisement
Add Comment
Please, Sign In to add comment