`
);
}
// Process calendar page
function processCalendarPage() {
// Torrent links
$('.grid-item[data-type="episode"]').each(function() {
addLinkToGridItem(this, 'episode');
});
// Autoscroll to current date
if (GM_config.get('autoscrollToday')) {
whenCalendarReady(() => {
// Extract the calendar date from the URL
let today = new Date();
let calendarDate = new Date(window.location.href.substring(window.location.href.lastIndexOf('/') + 1));
// If there's no date (current month) or it's current month then autoscroll
if(isNaN(calendarDate) || calendarDate.getMonth() === today.getMonth()) {
let todayCard = $('.date-separator:not(.filler) .date').filter(function () {
return $(this).text() == today.getDate();
}).first().get(0);
if (todayCard) {
todayCard.scrollIntoView(true);
let topNav = $('#top-nav').first().get(0);
let offset = -window.getComputedStyle(topNav).getPropertyValue('height').slice(0, -2);
window.scrollBy(0, offset);
}
}
}, 'autoscroll');
}
// Settings menu icon
$(
`
`
).on('click', () => GM_config.open())
.appendTo('.sidenav-inner');
// Add events to arrows
whenCalendarReady(() =>
// Add events to process page again if the user changes month
$('.prev, .next').on('click', () => whenCalendarReady(() =>
processCalendarPage(), 'processAfterChangingMonth')),
'addArrowsEvents');
applySettings();
}
// Process show page
function processShowPage() {
$('.grid-item[data-type="season"]').each(function() {
addLinkToGridItem(this, 'season');
});
}
// Process season page
function processSeasonPage() {
$('.grid-item[data-type="episode"]').each(function() {
addLinkToGridItem(this, 'episode');
});
addLinkToActionList($('.action-buttons'), 'season');
}
// Process episode page
function processEpisodePage() {
addLinkToActionList($('.action-buttons'), 'episode');
}
function processPage() {
if (regex.calendar.test(location.pathname)) {
processCalendarPage();
}
else if (regex.show.test(location.pathname)) {
processShowPage();
}
else if (regex.season.test(location.pathname)) {
processSeasonPage();
}
else if (regex.episode.test(location.pathname)) {
processEpisodePage();
}
}
processPage();
})();