Skip to content

Instantly share code, notes, and snippets.

@mjsqu
Created November 9, 2023 03:14
Show Gist options
  • Save mjsqu/a5fec14ccf71c129ecf89580346829a7 to your computer and use it in GitHub Desktop.
Save mjsqu/a5fec14ccf71c129ecf89580346829a7 to your computer and use it in GitHub Desktop.
Strava Challenge Climb Remaining Bookmarklet
/* 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