Category Archives: mashups

Bookmarklet for VAM on all segments in Strava

Have you ever created a segment with a short climb that just wasn’t quite long enough to be classified as a categorized climb in Strava?  You make a good time on the climb of the segment but VAM is not calculated…

A good effort, but no VAM to reward!

Well, here’s a little bookmarklet that adds VAM to each segment in your ride.  If it’s a downhill or flat segment, then the number won’t make much sense, but it is great for those short hard climbs.  This bookmarklet only changes the page, not the backend data, so if you reload, the tweaked VAM numbers will be gone.

After clicking the bookmarklet, note the updated VAM column!

Note also that the numbers calculated are based on the displayed elevation, distance and time values, which have been rounded, so VAM may not always come out quite the same as Strava’s more accurate calculations.

To use this bookmarklet:

  1. Right click on the following link and add it to favorites or bookmarks.
  2. When on a Strava ride page, click the bookmarklet.

The link:

Here’s the original, formatted code behind the link.

(function() {
  var t = document.getElementsByTagName(‘tr’);
  for(var i = 0; i < t.length; i++)
  {
    var tr = t[i];
    if(tr.className == ‘segment’)
    {
      var td_dist = tr.cells[3],
          td_elev = tr.cells[4],
          td_vam = tr.cells[7],
          td_time = tr.cells[9];
     
      var tm = td_time.innerHTML.split(‘:’),
          seconds = (parseInt(tm[0],10) * 60 + parseInt(tm[1],10)) * 60 + parseInt(tm[2],10),
          elev = parseInt(td_elev.innerHTML),
          dist = parseFloat(td_dist.innerHTML);
         
      var VAM = Math.round(elev * 3600 / seconds);
      var gradient = (elev / dist / 10).toFixed(1);
     
      var s = VAM.toString() + ‘ (‘ + gradient + ‘%)’;
     
      if(td_vam.innerHTML == ‘-‘ || td_vam.innerHTML.length > 4) td_vam.innerHTML = s;
      else td_vam.innerHTML += ‘ ‘ + s;
    }
  }
})();