Created
November 9, 2023 03:14
-
-
Save mjsqu/a5fec14ccf71c129ecf89580346829a7 to your computer and use it in GitHub Desktop.
Strava Challenge Climb Remaining Bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Construct day month year link for Strava Cycling Climbing Challenge */ | |
const d = new Date() | |
const m = d.toLocaleString('default', {'month':'long'}) | |
const y = d.getFullYear() | |
const url="https://www.strava.com/challenges/"+m+"-Cycling-Climbing-Challenge-"+y | |
window.location = url | |
/* Alert of climb per day remaining */ | |
var arrCalculation = document.querySelectorAll('[class*="ProgressBar--label-"]') | |
for (a of arrCalculation) { | |
for (c of a.classList) { | |
if (c.match('right')) { | |
var days = Number(a.innerHTML.replace(/[^0-9]/g, '')) | |
} | |
if (c.match('primary')) { | |
var climbed = Number(a.innerHTML.replace(/[^0-9]/g, '')) | |
} | |
if (c.match('left')) { | |
var total = Number(a.innerHTML.replace(/[^0-9]/g, '')) | |
} | |
} | |
} | |
alert(`You need to climb ${(total - climbed)/days} metres a day`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment