Simkl TV Next Episode Date

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

当前为 2021-06-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         Simkl TV Next Episode Date
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  Replaces "Airing" column with "Next Episode Date" column
// @author       jessequentin
// @match        https://simkl.com/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js
// ==/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>");
            })
        });
    }


    // store url on load
    let currentPage = location.href;
    let patt = /^http[s]?:\/\/simkl\.com\/\S+\/\S+\/watching\/$/gm;

    if(patt.test(currentPage)) {
      addNextEpisodeDate();
    }

    // listen for changes
    setInterval(function()
    {
      if (currentPage != location.href)
      {
        // page has changed, set new page as 'current'
        currentPage = location.href;

        if(patt.test(currentPage)) {
          addNextEpisodeDate();
        }
      }
    }, 500);
})();