Created
January 6, 2016 02:11
-
-
Save maxnordlund/a3d8c402b88c09942302 to your computer and use it in GitHub Desktop.
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
$$("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