Skip to content

Instantly share code, notes, and snippets.

@martinufo
Last active December 18, 2015 20:39
Show Gist options
  • Select an option

  • Save martinufo/5841547 to your computer and use it in GitHub Desktop.

Select an option

Save martinufo/5841547 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Runkeeper Average Speed
// @author Martin Stříž
// @namespace http://martinstriz.cz/
// @version 2013.06.22
// @description Shows average speed instead of average pace on certain activity types
// @include *runkeeper.com/user/*/activity/*
// ==/UserScript==
(function(){
var execute = function() {
var activityType = $("div.userHeader > h2").text();
if (activityType.indexOf('bike') !== -1 || activityType.indexOf('skate') !== -1) {
$("#averagePace > h5").text("Average speed")
var pace = $("#averagePace > h1 > span.value:first").text()
var parts = pace.split( ':' );
if (parts.length == 2) {
var min = parseInt(parts.slice( 0, 1 ).join(''));
var sec = parseInt(parts.slice( 1, 2 ).join(''));
var kmh = (Math.round(6000 / (min + sec / 60)) / 100).toFixed(2);
$("#averagePace > h1 > span.value").text(kmh);
}
}
}
var script = document.createElement("script");
script.innerHTML = '(' + execute.toString() + ')();';
document.head.appendChild(script);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment