forked from ZV3zrmCT/peloton_schwinn_metrics
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bookmarklet.js
1 lines (1 loc) · 4.48 KB
/
bookmarklet.js
1
javascript:(function()%7Bvar%20rideID%20%3D%20(rideID%20%3D%20window.location.pathname.split(%22%2F%22))%5BrideID.length%20-%201%5D%3Bfetch(%22https%3A%2F%2Fapi.onepeloton.com%2Fapi%2Fride%2F%22%20%2B%20rideID%20%2B%20%22%2Fdetails%3Fstream_source%3Dmultichannel%22%2C%20%7Bheaders%3A%20%7Baccept%3A%20%22application%2Fjson%2C%20text%2Fplain%2C%20*%2F*%22%2C%22accept-language%22%3A%20%22en-US%22%2C%22peloton-platform%22%3A%20%22web%22%2C%22sec-fetch-dest%22%3A%20%22empty%22%2C%22sec-fetch-mode%22%3A%20%22cors%22%2C%22sec-fetch-site%22%3A%20%22same-site%22%2C%22x-requested-with%22%3A%20%22XmlHttpRequest%22%7D%2Creferrer%3A%20%22https%3A%2F%2Fmembers.onepeloton.com%2Fclasses%2Fplayer%2F%22%20%2B%20rideID%2CreferrerPolicy%3A%20%22no-referrer-when-downgrade%22%2Cbody%3A%20null%2Cmethod%3A%20%22GET%22%2Cmode%3A%20%22cors%22%2Ccredentials%3A%20%22include%22%7D).then(function(e)%20%7Breturn%20e.json()%7D).then(function(i)%20%7Bvar%20a%20%3D%20%5B1%2C1%2C1%2C1%2C1%2C2%2C2%2C2%2C3%2C3%2C3%2C4%2C4%2C4%2C4%2C5%2C5%2C5%2C6%2C6%2C6%2C7%2C7%2C7%2C8%2C8%2C8%2C9%2C9%2C9%2C10%2C10%2C10%2C11%2C11%2C11%2C12%2C12%2C12%2C12%2C13%2C13%2C13%2C14%2C14%2C14%2C15%2C15%2C15%2C16%2C16%2C16%2C17%2C17%2C17%2C18%2C18%2C18%2C19%2C19%2C19%2C20%2C20%2C20%2C20%2C21%2C21%2C21%2C22%2C22%2C22%2C23%2C23%2C23%2C24%2C24%2C24%2C25%2C25%2C25%2C26%2C26%2C26%2C27%2C27%2C27%2C28%2C28%2C28%2C28%2C29%2C29%2C29%2C30%2C30%2C30%2C31%2C31%2C31%2C32%2C32%5D%2Co%20%3D%20Number(i.ride.duration)%2Ce%20%3D%20document.createElement(%22div%22)%3Be.id%20%3D%20%22cadresist%22%2C%20e.style%20%3D%20%22color%3Awhite%22%2C%20e.innerHTML%20%3D%20'%3Cdiv%20id%3D%22cadresisttxt%22%20style%3D%22width%3A100%25%3Bcolor%3Awhite%22%3E%3C%2Fdiv%3E%3Cdiv%20style%3D%22margin-top%3A10px%3Bwidth%3A100%25%3B%20height%3A2px%3B%20background-color%3A%23555555%22%3E%3Cdiv%20id%3D%22cadresistprogress%22%20style%3D%22width%3A0%25%3Btransition%3A990ms%20linear%3Bheight%3A2px%3Bbackground-color%3Awhite%22%3E%3C%2Fdiv%3E%3C%2Fdiv%3E'%2C%20document.querySelector(%22div%5Bdata-test-id%3D'videoSongContainer'%5D%22).after(e)%3Bvar%20c%20%3D%20document.getElementById(%22cadresisttxt%22)%2Cd%20%3D%20document.getElementById(%22cadresistprogress%22)%3Bif%20(!i.instructor_cues.length)%20return%20e.innerHTML%20%3D%20%22Class%20does%20not%20have%20target%20metrics.%22%2C%20void%20setTimeout(function()%20%7Be.innerHTML%20%3D%20%22%22%7D%2C%205e3)%3Bfor%20(var%20t%20%3D%20%5B%5D%2C%20r%20%3D%20i.instructor_cues%5B0%5D%2C%20n%20%3D%201%3B%20n%20%3C%20i.instructor_cues.length%3B%20n%2B%2B)%20%7Bvar%20s%20%3D%20i.instructor_cues%5Bn%5D%3Br.resistance_range.upper%20%3D%3D%20s.resistance_range.upper%20%26%26%20r.resistance_range.lower%20%3D%3D%20s.resistance_range.lower%20%26%26%20r.cadence_range.upper%20%3D%3D%20s.cadence_range.upper%20%26%26%20r.cadence_range.lower%20%3D%3D%20s.cadence_range.lower%20%3F%20r.offsets.end%20%3D%20s.offsets.end%20%3A%20(t.push(r)%2C%20r%20%3D%20s)%7Dt.push(s)%2C%20i.instructor_cues%20%3D%20t%2C%20console.dir(i.instructor_cues)%3Bvar%20u%20%3D%20document.querySelector(%22div%5Bdata-test-id%3D'video-timer'%5D%22)%3Bnew%20MutationObserver(function(e)%20%7Bvar%20t%20%3D%20document.querySelector(%22p%5Bdata-test-id%3D'time-to-complete'%5D%22)%3Bif%20(!t)%20return%3Bif%20(2%20!%3D%20(t%20%3D%20t.innerHTML.split(%22%3A%22)).length)%20return%3Bfor%20(var%20r%20%3D%20o%20-%20(60%20*%20Number(t%5B0%5D)%20%2B%20Number(t%5B1%5D))%20%2B%20Number(i.ride.pedaling_start_offset)%2C%20n%20%3D%200%3B%20n%20%3C%20i.instructor_cues.length%3B%20n%2B%2B)%20%7Bvar%20s%20%3D%20i.instructor_cues%5Bn%5D%3Bif%20(r%20%3E%3D%20Number(s.offsets.start)%20%26%26%20r%20%3C%3D%20Number(s.offsets.end))%20return%20c.innerHTML%20%3D%20%22cadence%3A%20%22%20%2B%20s.cadence_range.lower%20%2B%20%22%20-%20%22%20%2B%20s.cadence_range.upper%20%2B%20%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20resistance%3A%20%22%20%2B%20a%5Bs.resistance_range.lower%5D%20%2B%20%22%20-%20%22%20%2B%20a%5Bs.resistance_range.upper%5D%20%2B%20%22%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20(%22%20%2B%20s.resistance_range.lower%20%2B%20%22%20-%20%22%20%2B%20s.resistance_range.upper%20%2B%20%22)%22%2C%20void(r%20%3D%3D%20Number(s.offsets.start)%20%3F%20(d.style.transition%20%3D%20%22none%22%2C%20d.style.width%20%3D%20%220%25%22)%20%3A%20(d.style.transition%20%3D%20%22990ms%20linear%22%2C%20d.style.width%20%3D%20Math.round((r%20-%20s.offsets.start)%20%2F%20(s.offsets.end%20-%20s.offsets.start)%20*%20100)%20%2B%20%22%25%22))%7D%7D).observe(u%2C%20%7Battributes%3A%20!0%2CchildList%3A%20!0%2Csubtree%3A%20!0%2CcharacterData%3A%20!0%7D)%7D)%7D)()