// ==UserScript== // @name Total Duration Time + Total Episodes Of Any Animes Franchises // @namespace DurationByFranchise // @version 0.6 // @description This is a tool to easily and quickly see how long it will take for you to finish watching the whole anime Franchise, and you can also see how many episodes the Franchise has. // @author hacker09 // @include /^https:\/\/myanimelist\.net\anime\/[0-9]* // @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 var TotalEpsResult = []; //Creates a new blank array var TotalEpisodesTypeTV = ['0']; //Creates a new array var TotalEpisodesTypeOVA = ['0']; //Creates a new array var TotalEpisodesTypeONA = ['0']; //Creates a new array var TotalEpisodesTypeMusic = ['0']; //Creates a new array var TotalEpisodesTypeMovie = ['0']; //Creates a new array var TotalEpisodesTypeSpecial = ['0']; //Creates a new 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://api.allorigins.win/raw?url=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 var EpisodeType = TextElement[i].textContent.split("× ")[0].split(' |')[1]; //Creates a variable to check the episode types TotalEpsResult.push(TotalEpisodes); //Add The Eps To The Array 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 conditionn if (EpisodeType.match('Music') !== null) //If it's Music { //Starts the if condition TotalEpisodesTypeMusic.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition if (EpisodeType.match('TV') !== null) //If it's TV { //Starts the if conditionn TotalEpisodesTypeTV.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition if (EpisodeType.match('OVA') !== null) //If it's OVA { //Starts the if condition TotalEpisodesTypeOVA.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition if (EpisodeType.match('Special') !== null) //If it's Special { //Starts the if condition TotalEpisodesTypeSpecial.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition if (EpisodeType.match('ONA') !== null) //If it's ONA { //Starts the if condition TotalEpisodesTypeONA.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition if (EpisodeType.match('Movie') !== null) //If it's Movie { //Starts the if condition TotalEpisodesTypeMovie.push(TotalEpisodes); //Add The Eps To The Array } //Finishes the if condition } //Finishes the for condition var TotalEpsFinal = TotalEpsResult.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b); //Sum The Total Eps var TotalMinsResult = TotalHrMins.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b); //Sum Hrs in Mins + Total Mins var ONAEpisodesResult = TotalEpisodesTypeONA.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' ONA(s)'; //Sum The Total Eps var OVAEpisodesResult = TotalEpisodesTypeOVA.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' OVA(s)'; //Sum The Total Eps var TVEpisodesResult = TotalEpisodesTypeTV.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' TV Episode(s)'; //Sum The Total Eps var MusicEpisodesResult = TotalEpisodesTypeMusic.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' Music(s)'; //Sum The Total Eps var MovieEpisodesResult = TotalEpisodesTypeMovie.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' Movie(s)'; //Sum The Total Eps var SpecialEpisodesResult = TotalEpisodesTypeSpecial.filter(Boolean).map(i => Number(i)).reduce((a, b) => a + b)+' Special(s)'; //Sum The Total Eps //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; var title = 'title="'+OVAEpisodesResult+' '+ONAEpisodesResult+' '+MusicEpisodesResult+' '+SpecialEpisodesResult+' '+MovieEpisodesResult+' '+TVEpisodesResult+'"'; //Content that will be shown on mouse hover 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', '