// ==UserScript== // @name Total Duration Time Of Any Animes Franchises // @namespace DurationByFranchise // @version 0.2 // @description This is a tool to easily and quickly see how long it will take for you to finish watching the whole anime Franchise. // @author hacker09 // @match https://myanimelist.net/anime/* // @match https://myanimelist.net/anime.php?id=* // @match https://chiaki.site/?/tools/watch_order/id/* // @match https://chiaki.site/?/tools/watch_order/group_id/* // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; var TotalHrMins = []; //Creates a new blank array if (top.location.host === 'myanimelist.net') { var animeid = location.pathname.match(/\d+/)[0]; //Detect the anime id } async function ProcessRawTextContent() //Creates a function to Process the RawTextContent { //Starts the function if (top.location.host === 'myanimelist.net') //If The User Is On The https://myanimelist.net/ Website Fetch Chiaki { //Starts the if condition var IsUserOnMAL = true; const response = await fetch('https://cors-anywhere.herokuapp.com/https://chiaki.site/?/tools/watch_order/id/'+animeid); //Fetch const html = await response.text(); //Gets the fetch response const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response var TextElement = newDocument.querySelectorAll("span.uk-text-muted.uk-text-small"); //Creates a variable to loop though the elements after } //Finishes the if condition else //If The User Is On The https://chiaki.site/ Website Start Processing The Content { //Starts the else condition var IsUserOnMAL = false; var TextElement = document.querySelectorAll("span.uk-text-muted.uk-text-small"); //Creates a variable to loop though the elements after } //Finishes the else condition for (var i = 0; i < TextElement.length; i++) { //Starts the for condition var TotalRawDuration = TextElement[i].textContent.split("× ")[1].split(' |')[0].match(/\d+|\?/g); //Creates a variable to hold the total unprocessed times var TotalEpisodes = TextElement[i].textContent.split("× ")[0].split(' |')[2].match(/\d+|\?/g); //Creates a variable to hold the total episodes if (TotalRawDuration.length !== 1) //If has Hrs and Mins { //Starts the if condition var ExtractHrs = TotalRawDuration[0] * 60; //Extract Hrs And Convert To Mins var TotalHrs = TotalEpisodes * ExtractHrs; //Multiply Eps By Hrs var TotalMins = TotalEpisodes * TotalRawDuration[1]; //Multiply Extracted Eps By Mins TotalHrMins.push(TotalHrs, TotalMins); //Add Hrs And Mins To The Array } //Finishes the if condition else //Extract only Mins { //Starts the else condition var TotalMins = TotalEpisodes * TotalRawDuration[0]; //Multiply Extracted Eps By Mins TotalHrMins.push(TotalMins); //Add Mins To The Array } //Finishes the else condition } //Finishes the for condition var TotalMinsResult = TotalHrMins.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b); //Sum Hrs in Mins + Total Mins //The Commands Below Converts The Total Franchise Time To Precise Hours And Minutes var days = Math.floor(TotalMinsResult / 1440); var hours = Math.floor((TotalMinsResult % 1440) / 60); var minutes = (TotalMinsResult % 1440) % 60; if (IsUserOnMAL) //If The User Is On The https://myanimelist.net/ Website { function findTheInformationheader() { const headers = [...document.querySelectorAll("h2")]; //Select all h2 elements on MAL return headers.find(h2 => h2.textContent === "Information"); } //Find the h2 element that has the text Information function findTheRatingText() { const allInfo = [...findTheInformationheader().parentNode.querySelectorAll("div")]; //Select all divs inside the Information h2 element return allInfo.find(info => info.innerText.includes("Rating")); } //Find the Rating text that's inside the information h2 element findTheRatingText().insertAdjacentHTML('beforeend', '
Total Franchise Duration: ' + days + ' day(s) ' + hours + ' hr(s) ' + minutes + ' min(s)
'); //Show The Total Duration } else //If The User Is On The https://chiaki.site/ Website { document.querySelector("ul.uk-flex-center.noborder.uk-tab").insertAdjacentHTML('beforeend', '
  • Total Duration: ' + days + ' day(s) ' + hours + ' hr(s) ' + minutes + ' min(s)
  • '); //Show The Total Duration } } //Finishes the async function ProcessRawTextContent(); //Starts the function })();