Skip to content

Instantly share code, notes, and snippets.

@linssen
Created October 31, 2016 12:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linssen/ed3d392b406805346214e96a9136724a to your computer and use it in GitHub Desktop.
Save linssen/ed3d392b406805346214e96a9136724a to your computer and use it in GitHub Desktop.
Bulk editing strava activities from https://www.strava.com/athlete/training
(function($) {
var $rows = $('.training-activity-row');
/**
* Edit row
*
* @param {Dom} row
*/
function EditRow(row) {
this.$row = $(row);
this.$row.find('.quick-edit').click();
window.setTimeout(this.edit.bind(this), 500);
}
/** Edit the row */
EditRow.prototype.edit = function() {
var time = this.$row.find('[data-field-name="time"]').text().split(':').reverse();
var mins = parseInt(time[1], 10) + parseInt(time[2] || 0, 10) * 60;
var isCommute = mins < 25;
this.$row.find('[name="commute"]').prop('checked', isCommute);
if (isCommute) console.log('Marking as commute');
// Submit the form
this.$row.find('button[type="submit"]').click();
};
$rows.each(function() { new EditRow(this); });
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment