Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dlh3/e077dc56c69ef418e0dba0e3f3f47b88 to your computer and use it in GitHub Desktop.
Save dlh3/e077dc56c69ef418e0dba0e3f3f47b88 to your computer and use it in GitHub Desktop.
A bookmarklet (tested in Chrome) which will calculate the delta/elapsed time between your PR and the CR on all starred segments on Strava
javascript: /* Are we on the starred segments page? If not, redirect to there. */ if (document.location.href.replace(document.location.search, "") != "https://www.strava.com/athlete/segments/starred") { document.location = "https://www.strava.com/athlete/segments/starred"; }; function toSeconds(timestamp) { return timestamp.length == 1 ? timestamp[0].replace('s', '') : parseInt(timestamp[0]) * 60 + parseInt(timestamp[1]); }; var jq = document.createElement('script'); jq.src = '//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'; document.getElementsByTagName('head')[0].appendChild(jq); jq.onload = () => {/* Have we already processed the segments? */ if (window.Strava.segmentsProcessed) { return 0; }; window.Strava.segmentsProcessed = 0; $('.starred-segments tbody tr').each((i, e) => { window.Strava.segmentsProcessed++; var $row = $(e), $name = $row.children('td:nth-child(3)'), men = toSeconds($row.children('td:nth-child(8)').text().split(':')), me = toSeconds($row.children('td:nth-child(10)').text().split(':')), delta = me - men, name = $name.html(); $name.html(`[${delta ? delta + ' seconds' : (delta == 0 ? 'CR' : '--')}] ${name}`); }); };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment