Advertisement
Guest User

gc-deviceid-2023

a guest
Jul 6th, 2023
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getDeviceInfo() {
  2.     let rootURL = "https://connect.garmin.com/modern/activity/";
  3.     let loc = window.location.href;
  4.     if (loc.indexOf(rootURL) != 0) {
  5.         alert("This bookmarklet script must be run on GC device page (with a URL starting with " + rootURL + ")")
  6.         return;
  7.     }
  8.  
  9.     let activityID = loc.replace(rootURL, "");
  10.     var xhr = new XMLHttpRequest();
  11.     xhr.open('GET', 'https://connect.garmin.com/modern/proxy/activity-service/activity/' + activityID);
  12.     xhr.setRequestHeader("NK", "NT")
  13.     xhr.onload = function () {
  14.         let obj = JSON.parse(xhr.response)
  15.         let deviceID = obj.metadataDTO.deviceMetaDataDTO.deviceId;
  16.         alert('The device ID for this activity is: ' + deviceID)
  17.     };
  18.     xhr.send()
  19. }
  20. getDeviceInfo();
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement