Skip to content

Instantly share code, notes, and snippets.

@maxnordlund
Created January 6, 2016 02:11
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 maxnordlund/a3d8c402b88c09942302 to your computer and use it in GitHub Desktop.
Save maxnordlund/a3d8c402b88c09942302 to your computer and use it in GitHub Desktop.
$$("tbody td:first-child:not([colspan])").forEach(function use24hclock(td) {
td.textContent = moment(td.textContent, "hh:mm a").format("HH:mm")
})
function markAired() {
var date, i, style, td, tr,
tds = Array.from(document.querySelectorAll(
"tbody td:first-child:not([colspan])"
))
for (i = 0; i < tds.length; ++i) {
td = tds[i]
// Find the correct tr with the date of the current run
for(tr = td.parentElement; tr.className !== "day-split"; tr = tr.previousElementSibling) {}
date = moment(tr.textContent + td.textContent, "dddd, MMMM Do HH:mm", "en")
if (date.isBefore()) {
style = td.parentElement.style
style.opacity = 0.5
style.fontWeight = ""
} else { // The next run to air
if (tds[i-1]) {
style = tds[i-1].parentElement.style
style.opacity = 1
style.fontWeight = "bold"
}
// Wait until 5 seconds after the next has started
setTimeout(markAired, date.add({ seconds: 5 }).diff())
return
}
}
}
markAired()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment