Created
October 31, 2016 12:13
-
-
Save linssen/ed3d392b406805346214e96a9136724a to your computer and use it in GitHub Desktop.
Bulk editing strava activities from https://www.strava.com/athlete/training
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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