Created
July 5, 2017 11:33
-
-
Save nietonfir/977ecb579c065ac0e66b5f47772060fd to your computer and use it in GitHub Desktop.
Jump to the current active game in the "Games Done Quick" schedule
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
// paste this in your browser console | |
// at https://gamesdonequick.com/schedule | |
(function($) { | |
$.getScript('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js', function() { | |
var now = moment(), | |
search = now.format('dddd, MMMM Do'); | |
$('.day-split').each(function(i, e) { | |
var $ele = $(e); | |
if ($ele.children().eq(0).text().trim() == search) { | |
var $prev, | |
$set = $ele.nextUntil('.day-split').filter(':not(.second-row)'), | |
lastIdx = $set.length - 1; | |
$set.each(function(j, f) { | |
var $cur = $(f), | |
$time = $cur.children('.start-time'), | |
parsedTime = moment(search + ' ' + $time.text().trim(), 'dddd, MMMM Do h:mm A'); | |
if ((parsedTime.isValid() && parsedTime.isAfter(now)) || (j === lastIdx) ) { | |
$prev = (j === 0 || j === lastIdx) ? $cur : $prev; | |
$('html,body').scrollTop($prev.offset().top); | |
return false; | |
} else { | |
$prev = $cur; | |
} | |
}); | |
return false; | |
} | |
}); | |
}) | |
})( jQuery ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment