Greasy Fork is available in English.

Simkl TV Next Episode Date

Replaces "Airing" column with "Next Episode Date" column

As of 07/10/2020. See the latest version.

// ==UserScript==
// @name         Simkl TV Next Episode Date
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Replaces "Airing" column with "Next Episode Date" column
// @author       jessequentin
// @match        https://simkl.com/*/tv/*
// @grant        window.onurlchange
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js
// @require  https://greasyfork.org/scripts/6250-waitforkeyelements/code/waitForKeyElements.js?version=23756
// ==/UserScript==
(function() {
    'use strict';
    var $ = window.jQuery;
    function addNextEpisodeDate () {
        $("img[alt='Airing']").closest("a").text("Next Episode Date");

        $(".SimklTVMyTableTRTitle").each(function() {
            var showlink = $(this).find("a").attr('href');
            $(this).siblings(".SimklTVMyTableTRAiring").load( showlink + " .SimklTVAboutBlockBottomEpisodes > table ", function () {
                $(this).find('.SimklTVAboutBlockEpisodeWhich:contains("Previous")').closest("table").replaceWith("<div class=TBD>TBD</div>");
                var smtab=$(this).find('.SimklTVAboutBlockEpisodeWhich').closest("table");
                $(smtab).closest("td").each(function() { $(this).siblings().remove(); });
                var infotab=$(smtab).find("a[rel='nofollow']").first().closest("td");
                $(smtab).find("a[rel='nofollow']").replaceWith(function() { return this.innerHTML; });
                $(this).find('.SimklTVAboutBlockEpisodeWhich').closest("tr").remove();
                $(this).find('.TBD').closest("td").each(function() { $(this).siblings().remove(); });
                $(this).find('span').replaceWith(function() { return this.innerHTML; });
                var eplink=$(infotab).siblings().first().find("a").attr("href");
                var infostring=$(infotab).text();
                var infodate=infostring.match(/[0-9]+\-[0-9]+\-[0-9]+/g);
                infodate=infodate?String(infodate).replace(/\-/g,"/"):"TBD";
                var airdate = (infodate&&infodate!="TBD")?Date.parse(infodate):14399999996400;
                if(!eplink) eplink=showlink;
                $(this).replaceWith('<td class="SimklTVMyTableTRAiring SimklTVMyTableTRTitle" width="155"><a href="'+eplink+'"><span>'+airdate+"</span>"+infodate+"</a></td>");
            })
        });
    }
    waitForKeyElements (".SimklTVMyTableTRbottom", addNextEpisodeDate);
})();