Finish Airing Date - MAL

Calculate the expected finished airing date for anime entries.

当前为 2023-12-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Finish Airing Date - MAL
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      1
// @description  Calculate the expected finished airing date for anime entries.
// @author       hacker09
// @match        https://myanimelist.net/anime/*
// @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  var startDateElement = [...[...document.querySelectorAll("h2")].find(h2 => h2.textContent === "Information").parentNode.querySelectorAll("div")].find(info => info.innerText.includes("Aired")).querySelector("span"); //Get the start date from the page
  if (startDateElement.parentNode.textContent.match(/\?/) !== null && document.querySelector("#curEps").innerText !== '?') { //If the finished date is unkown and the total entry eps are known
    var startDateMatch = startDateElement.parentNode.textContent.match(/(\w{3})\s(\d{1,2}),\s(\d{4})/); //Save the start date
    var month = {'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12}[startDateMatch[1]]; //Convert start month to number
    var startDate = new Date(parseInt(startDateMatch[3]), month - 1, parseInt(startDateMatch[2])); //Save start date Year, month, day
    var expectedFinishedAiringDate = new Date(startDate.getTime() + parseInt(document.querySelector("#curEps").innerText) * 7 * 24 * 60 * 60 * 1000); //Calculate the expected finished date

    startDateElement.parentNode.className += ' dark_text'; //Make the text bold
    startDateElement.nextSibling.textContent = startDateElement.nextSibling.textContent.replace(/\?/g, ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][expectedFinishedAiringDate.getMonth()] + ' ' + expectedFinishedAiringDate.getDate() + ', ' + expectedFinishedAiringDate.getFullYear()); //Replace ? with the finished and formated date
  } //Finishes the if condition
})();