// ==UserScript== // @name AniList MultiTitle Display // @namespace http://tampermonkey.net/ // @version 0.1 // @description Adds the non-primary titles to the title display. // @author Bane // @match https://anilist.co/anime/* // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js // @require http://code.jquery.com/jquery-3.4.1.min.js // @grant none // @downloadURL none // ==/UserScript== function GetTitles() { //The already existing title var aniTitle = document.querySelector("#app > div.page-content > div > div.header-wrap > div.header > div.container > div.content > h1") aniTitle.innerHTML = aniTitle.innerText; //Replace the HTML with the innerText cuz it's neater var oldTitle = aniTitle.innerText; //Store the user preference aniTitle.innerHTML += "

" //Add line breaks to separate the preference from the others var sets = document.getElementsByClassName("data-set"); //Searched all the data values on the sidebar var title = ""; //Creates empty title string for later //The types we are looking to add var types = ["Romaji", "English", "Native"]; SetTitles(); function SetTitles() { for(var i = 0; i < sets.length; i++) { //Get the type we are looking at in the loop var typeCheck = sets[i].getElementsByClassName("type")[0].innerText; //If the type is in our wanted types... if(types.indexOf(typeCheck) > -1) { //...continue and add it to the title. console.log("Right Ani type found"); AddTitle(i); } } } function AddTitle(i) { title = sets[i].getElementsByClassName("value")[0].innerHTML; //Get the text from the value. title = title.replace(/ +/g, " "); //Removes double spaces (for some reason there's a few, such as at https://anilist.co/anime/98448/) if(title != oldTitle) //If the title is NOT the same as the user preference one... { //...add it. aniTitle.innerHTML += title + "
"; } } } (function() { 'use strict'; var checkExist = setInterval(function() { var loadCheck = document.getElementsByClassName("data-set"); if (loadCheck.length) { console.log("Anilist has loaded!"); clearInterval(checkExist); GetTitles(); } }, 100); // check every 100ms })();