Finish Airing Date - MAL

Calculate the expected finished airing date for anime entries.

目前為 2023-12-18 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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
})();