// ==UserScript==
// @name Automatically Add Start/Finish Dates For Animes/Mangas + Helpful Buttons
// @namespace Add End And Start Dates In 1 Click + Reset Dates/All Buttons,
// @version 2.0.0.7
// @description Select Watching/Reading to auto add the start date, select Completed to auto add the finish date. The script shows the actual Anime/Manga dates below the Anime/Manga image, that's updated every time you reload or click on Watching/Reading/Completed. Hover the mouse on the dates and click to reset them. This script adds 6 helpful buttons on the Anime/Manga Edit Details Page.
// @author hacker09
// @match https://myanimelist.net/ownlist/*
// @include /^https:\/\/myanimelist\.net\/anime\/[\d]+(\/.*)?/
// @include /^https:\/\/myanimelist\.net\/manga\/[\d]+(\/.*)?/
// @icon https://www.google.com/s2/favicons?domain=myanimelist.net
// @run-at document-end
// @grant GM_addStyle
// ==/UserScript==
(function() {
'use strict';
if (window.location.pathname.split('/')[1] === 'ownlist') //Check If The User Is On https://myanimelist.net/ownlist/ ,And If Yes These Codes Will Run
{
var entrytype = window.location.pathname.split('/')[2]; //Get the entry type
var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
//**********************************************************************************************************************************************************************
var ResetBTNStart = document.createElement("a"); //Creates an a element
ResetBTNStart.innerHTML = "Reset"; //Adds the text to the element
document.querySelector("#start_date_insert_today").parentElement.appendChild(ResetBTNStart); //Shows the button
ResetBTNStart.setAttribute("id", "resetstart"); //Adds an id to the button
ResetBTNStart.setAttribute("style", "cursor: pointer;margin-left: 5px;height: 10px;width: 10px;top: 10px;"); //Sets the button css style
document.getElementById('resetstart').onclick = function() { //Adds an advent listener to the button
document.getElementById("add_" + entrytype + "_start_date_year").selectedIndex = -1; //Reset the start year
document.getElementById("add_" + entrytype + "_start_date_day").selectedIndex = -1; //Reset the start day
document.getElementById("add_" + entrytype + "_start_date_month").selectedIndex = -1; //Reset the start month
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
var ResetBTNEnd = document.createElement("a"); //Creates an a element
ResetBTNEnd.innerHTML = "Reset"; //Adds the text to the element
document.querySelector("#end_date_insert_today").parentElement.appendChild(ResetBTNEnd); //Shows the button
ResetBTNEnd.setAttribute("id", "resetend"); //Adds an id to the button
ResetBTNEnd.setAttribute("style", "cursor: pointer;margin-left: 5px;height: 10px;width: 10px;top: 10px;"); //Sets the button css style
document.getElementById('resetend').onclick = function() { //Adds an advent listener to the button
document.getElementById("add_" + entrytype + "_finish_date_year").selectedIndex = -1; //Reset the finish year
document.getElementById("add_" + entrytype + "_finish_date_day").selectedIndex = -1; //Reset the finish day
document.getElementById("add_" + entrytype + "_finish_date_month").selectedIndex = -1; //Reset the finish month
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
var AddDates = document.createElement("a"); //Creates an a element
AddDates.innerHTML = "Add End And Start Dates + Submit"; //Adds the text to the element
document.querySelector('.notice_open_public').appendChild(AddDates); //Shows the button
AddDates.setAttribute("id", "addalldates"); //Adds an id to the button
AddDates.setAttribute("style", "cursor: pointer;margin-left: 5px;height: 10px;width: 10px;top: 10px;"); //Sets the button css style
document.getElementById('addalldates').onclick = function() { //Adds an advent listener to the button
document.getElementById("start_date_insert_today").click(); //Adds the start date
document.getElementById("end_date_insert_today").click(); //Adds the finish date
document.getElementsByClassName("inputButton main_submit")[0].click(); //Submit
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
var InsertStart = document.createElement("a"); //Creates an a element
InsertStart.innerHTML = "Insert + Submit"; //Adds the text to the element
function findTheInStartDateTd() { //Find the td element that thas the test "Start Date"
const headers = [...document.querySelectorAll("td")]; //Select all the td elements
return headers.find(td => td.textContent === "Start Date"); //Find the td element that has the text "Start Date"
} //Finishes the findTheInStartDateTd function
findTheInStartDateTd().nextElementSibling.setAttribute("style", "padding: 14px;"); //Sets the td element css style
findTheInStartDateTd().parentElement.appendChild(InsertStart); //Shows the button
InsertStart.setAttribute("id", "InsertStart"); //Adds an id to the button
InsertStart.setAttribute("style", "cursor: pointer;margin-left: -200px;"); //Sets the button css style
document.getElementById('InsertStart').onclick = function() { //Adds an advent listener to the button
document.getElementById("start_date_insert_today").click(); //Adds the start date
document.getElementsByClassName("inputButton main_submit")[0].click(); //Submit
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
var InsertEnd = document.createElement("a"); //Creates an a element
InsertEnd.innerHTML = "Insert + Submit"; //Adds the text to the element
function findTheInFinishDateTd() { //Find the td element that thas the test "Finish Date"
const headers = [...document.querySelectorAll("td")]; //Select all the td elements
return headers.find(td => td.textContent === "Finish Date"); //Find the td element that has the text "Finish Date"
} //Finishes the findTheInFinishDateTd function
findTheInFinishDateTd().nextElementSibling.setAttribute("style", "padding: 14px;"); //Sets the td element css style
findTheInFinishDateTd().parentElement.appendChild(InsertEnd); //Shows the button
InsertEnd.setAttribute("id", "InsertEnd"); //Adds an id to the button
InsertEnd.setAttribute("style", "cursor: pointer;margin-left: -200px;"); //Sets the button css style
document.getElementById('InsertEnd').onclick = function() { //Adds an advent listener to the button
document.getElementById("end_date_insert_today").click(); //Adds the finish date
document.getElementsByClassName("inputButton main_submit")[0].click(); //Submit
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
var ResetAlmostAll = document.createElement("a"); //Creates an a element
ResetAlmostAll.innerHTML = "Reset Almost Everything"; //Adds the text to the element
document.querySelector("#advanced-button").parentElement.appendChild(ResetAlmostAll); //Shows the button
ResetAlmostAll.setAttribute("id", "resetalmostall"); //Adds an id to the button
ResetAlmostAll.setAttribute("style", "cursor: pointer;margin-left: 240px;"); //Sets the button css style
document.getElementById('resetalmostall').onclick = function resetSelectElement() { //Adds an advent listener to the button
$('select').prop('selectedIndex', 0); //Resets almost all form fields
document.getElementById("unknown_end").click(); //Unmark the box "unknown_end"
}; //Finishes the advent listener
//**********************************************************************************************************************************************************************
setTimeout(function() { //Starts the timeout condition
if (document.querySelectorAll("#hide-advanced-button")[0].outerText !== "Hide Advanced ") //Detect if the Show Advanced button is already opened or not,if not then...
{ //Starts the if condition
document.querySelector("#hide-advanced-button").click(); //Clicks on the Show Advanced button
} //Finishes the if condition
}, 0); //Finishes the timeout condition
} //Finishes the if condition
//**********************************************************************************************************************************************************************
else //If the user is on a manga/anime page
{ //Starts the if condition
var d = new Date(); //Creates a variable called d that will hold the computer date on the local time zone
var day = d.getDate(); //Creates a variable to hold the actual day
var month = d.getMonth() + 1; //Creates a variable to hold the actual month
var year = d.getFullYear(); //Creates a variable to hold the actual year
var entrytype2 = window.location.pathname.split('/')[1]; //Creates a variable to hold the actual entry type
var token = document.head.querySelector("[name='csrf_token']").content; //Creates a variable to hold the actual csrf_token
var entryid = location.pathname.match(/\d+/)[0]; //Creates a variable to hold the actual entry id
var priority, is_asked_to_discuss, sns_post_type, start_month, start_day, start_year, finish_month, finish_day, finish_year, watched_eps, current_score, anime_tags, storage_type, storage_value, rewatched_times, rewatch_value, comments, manga_read_chapters, manga_retail, manga_read_times, manga_reread_value, manga_read_volumes, status, IsEditPageOpened; //Make all these variables global
if (entrytype2 === 'anime') //If the entry type is anime, get the total episodes number
{ //Starts the if condition
var totaleps = document.querySelector("#curEps").textContent; //Get the actual total episodes value
} //Finishes the if condition
else //If the entry type is manga
{ //Starts the else condition
var totalVols = document.querySelector("#totalVols").textContent; //Get the actual total manga volumes
var totalChaps = document.querySelector("#totalChaps").textContent; //Get the actual total manga chapters
} //Finishes the else condition
async function ShowButtons() //Creates a function to show the Buttons
{ //Starts the function
//Starts the codes to Display the Started Date
if ((start_month !== "") || (start_day !== "") || (start_year !== "")) // If month or date or year is set in the started dates then show the button
{ //Starts the if condition
var ResetStartDate = document.createElement("div"); //Creates the button to reset the start date
ResetStartDate.innerHTML = 'Started: Month:' + start_month + ' Day:' + start_day + ' Year:' + start_year; //Define the button text
document.querySelector("#profileRows").append(ResetStartDate); //Append the button below the "add to favorites" button
ResetStartDate.setAttribute("id", "ResetStartDate"); //Gives an id to the button
if (document.querySelectorAll("#ResetStartDate").length > 1) //If the button already exits
{ //Starts the if condition
document.querySelector("#ResetStartDate").remove(); //Remove the old button
} //Finishes the if condition
ResetStartDate.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the page loads
document.querySelector("#ResetStartDate").onmousemove = function() { //Set the css for the button when the mouse is hovering the button
ResetStartDate.innerHTML = "Reset Started Date"; //Change the element text
ResetStartDate.setAttribute("style", "cursor: pointer;background-color: #1d439b;border-color: #6386d5;border-style: solid;border-width: 0 0 1px;color: #fff;padding: 2px 3px;"); //Make the element look like it's clickable and change the element color
}; //Finishes the css for the button when the mouse is hovering the button
document.querySelector("#ResetStartDate").onmouseout = function() {
ResetStartDate.innerHTML = 'Started: Month:' + start_month + ' Day:' + start_day + ' Year:' + start_year;
ResetStartDate.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the mouse is not hovering the button
}; //Set the css for the button when the mouse is leaves the button
document.querySelector("#ResetStartDate").addEventListener("click", ResetStartDateFunc, false); //When the button is cliked call this function
} //Finishes the if condition
//Starts the codes to Display the Finished Date
if ((finish_month !== "") || (finish_day !== "") || (finish_year !== "")) // If month or date or year is set in the finished dates then show the button
{ //Starts the if condition
var ResetFinishDate = document.createElement("div"); //Creates the button to reset the finish date
ResetFinishDate.innerHTML = 'Finished: Month:' + finish_month + ' Day:' + finish_day + ' Year:' + finish_year; //Define the button text; //Define the button text
document.querySelector("#profileRows").append(ResetFinishDate); //Append the button below the "add to favorites" button
ResetFinishDate.setAttribute("id", "ResetFinishDate"); //Gives an id to the button
if (document.querySelectorAll("#ResetFinishDate").length > 1) //If the button already exits
{ //Starts the if condition
document.querySelector("#ResetFinishDate").remove(); //Remove the old button
} //Finishes the if condition
ResetFinishDate.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the page loads
document.querySelector("#ResetFinishDate").onmousemove = function() { //Set the css for the button when the mouse is hovering the button
ResetFinishDate.innerHTML = "Reset Finished Date"; //Change the element text
ResetFinishDate.setAttribute("style", "cursor: pointer;background-color: #1d439b;border-color: #6386d5;border-style: solid;border-width: 0 0 1px;color: #fff;padding: 2px 3px;"); //Make the element look like it's clickable and change the element color
}; //Finishes the css for the button when the mouse is hovering the button
document.querySelector("#ResetFinishDate").onmouseout = function() {
ResetFinishDate.innerHTML = 'Finished: Month:' + finish_month + ' Day:' + finish_day + ' Year:' + finish_year;
ResetFinishDate.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the mouse is leaves the button
}; //Set the css for the button when the mouse is hovering the button
document.querySelector("#ResetFinishDate").addEventListener("click", ResetFinishDateFunc, false); //When the button is cliked call this function
} //Finishes the if condition
//Starts the codes to Display the Reset All Dates
if ((finish_month !== "" || finish_day !== "" || finish_year !== "") && (start_month !== "" || start_day !== "" || start_year !== "")) // If month or date or year is set in the started and finished dates then show the button
{ //Starts the if condition
var ResetAllDatesVar = document.createElement("div"); //Creates the button to reset all dates
ResetAllDatesVar.innerHTML = "Reset Started+Finished Dates"; //Define the button text
document.querySelector("#profileRows").append(ResetAllDatesVar); //Append the button below the "add to favorites" button
ResetAllDatesVar.setAttribute("id", "ResetAllDatesVar"); //Gives an id to the button
if (document.querySelectorAll("#ResetAllDatesVar").length > 1) //If the button already exits
{ //Starts the if condition
document.querySelectorAll("#ResetAllDatesVar")[0].remove(); //Remove the old button.There's no real need to update this button again, but if isn't updated the onmousemove/out won't work
} //Finishes the if condition
ResetAllDatesVar.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the page loads
document.querySelector("#ResetAllDatesVar").onmousemove = function() { //Set the css for the button when the mouse is hovering the button
ResetAllDatesVar.setAttribute("style", "cursor: pointer;background-color: #1d439b;border-color: #6386d5;border-style: solid;border-width: 0 0 1px;color: #fff;padding: 2px 3px;"); //Make the element look like it's clickable and change the element color
}; //Finishes the css for the button when the mouse is hovering the button
document.querySelector("#ResetAllDatesVar").onmouseout = function() { //Set the css for the button when the mouse isn't hovering the button
ResetAllDatesVar.setAttribute("style", "border-top: #92b0f1 1px solid;border-color: #92b0f1;border-style: solid;border-width: 0 0 1px;color: #1d439b;cursor: pointer;padding: 2px 3px;"); //Set the css for the button when the mouse is leaves the button
}; //Fnishrd the css for the button when the mouse isn't hovering the button
document.querySelector("#ResetAllDatesVar").addEventListener("click", ResetAllDates, false); //When the button is cliked call this function
} //Finishes the if condition
} //Finishes the async ShowButtons function
async function getVariables() //Creates a function to get the needed Variables
{ //Starts the function
const response = await fetch('https://myanimelist.net/ownlist/' + entrytype2 + '/' + entryid + '/edit'); //Fetch
const html = await response.text(); //Gets the fetch response
const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
priority = newDocument.querySelector("#add_" + entrytype2 + "_priority").value; //Creates a variable to hold the actual priority value
is_asked_to_discuss = newDocument.querySelector("#add_" + entrytype2 + "_is_asked_to_discuss").value; //Creates a variable to hold the actual is_asked_to_discuss value
sns_post_type = newDocument.querySelector("#add_" + entrytype2 + "_sns_post_type").value; //Creates a variable to hold the actual SNS value
start_day = newDocument.querySelector("#add_" + entrytype2 + "_start_date_day").value; //Creates a variable to hold the actual start_day value
start_month = newDocument.querySelector("#add_" + entrytype2 + "_start_date_month").value; //Creates a variable to hold the actual start_month value
start_year = newDocument.querySelector("#add_" + entrytype2 + "_start_date_year").value; //Creates a variable to hold the actual start_year value
finish_day = newDocument.querySelector("#add_" + entrytype2 + "_finish_date_day").value; //Creates a variable to hold the actual finish_day value
finish_month = newDocument.querySelector("#add_" + entrytype2 + "_finish_date_month").value; //Creates a variable to hold the actual finish_month value
finish_year = newDocument.querySelector("#add_" + entrytype2 + "_finish_date_year").value; //Creates a variable to hold the actual finish_year value
current_score = newDocument.querySelector("#add_" + entrytype2 + "_score").value; //Creates a variable to hold the actual current_score value
anime_tags = newDocument.querySelector("#add_" + entrytype2 + "_tags").value; //Creates a variable to hold the actual anime_tags value
storage_type = newDocument.querySelector("#add_" + entrytype2 + "_storage_type").value; //Creates a variable to hold the actual storage_type value
comments = newDocument.querySelector("#add_" + entrytype2 + "_comments").value; //Creates a variable to hold the actual comments value
status = newDocument.querySelector("#add_" + entrytype2 + "_status").value; //Creates a variable to hold the actual status value
if (entrytype2 === 'anime') //If the entry type is anime
{ //Starts the if condition
watched_eps = newDocument.querySelector("#add_anime_num_watched_episodes").value; //Creates a variable to hold the actual watched_eps value
storage_value = newDocument.querySelector("#add_anime_storage_value").value; //Creates a variable to hold the actual storage_value value
rewatched_times = newDocument.querySelector("#add_anime_num_watched_times").value; //Creates a variable to hold the actual rewatched_times value
rewatch_value = newDocument.querySelector("#add_anime_rewatch_value").value; //Creates a variable to hold the actual rewatch_value value
} //Finishes the if condition
else //If the entry type is manga
{ //Starts the else condition
manga_read_chapters = newDocument.querySelector("#add_manga_num_read_chapters").value; //Creates a variable to hold the actual manga_read_chapters value
manga_retail = newDocument.querySelector("#add_manga_num_retail_volumes").value; //Creates a variable to hold the actual manga_retail value
manga_read_times = newDocument.querySelector("#add_manga_num_read_times").value; //Creates a variable to hold the actual manga_read_times value
manga_reread_value = newDocument.querySelector("#add_manga_reread_value").value; //Creates a variable to hold the actual manga_read_times value
manga_read_volumes = newDocument.querySelector("#add_manga_num_read_volumes").value; //Creates a variable to hold the actual manga_read_volumes value
} //Finishes the else condition
await ShowButtons(); //Call and wait the function ShowButtons to Display the buttons
} //Finishes the async getvariables function
if (document.querySelector("#myinfo_status.btn-user-status-add-list.js-form-user-status.js-form-user-status-btn.myinfo_addtolist") === null) { //If the anime is on the user list
var AddedToList = true;
var TimesExecuted = 0; //Creates a new variable
var increaseby = 1; //Creates a new variable
window.onscroll = async function() { //Creates a new function to run when the page is scrolled
TimesExecuted += increaseby; //Sum the amount of times that the page was scrolled
if (TimesExecuted === 1) { //On the first time that the page is scrolled
getVariables(); //Call and wait the function getVariables
} // //Finishes the if condition
}; //Finishes the onscroll advent listener
} //Finishes the if condition
GM_addStyle(".loading{position: fixed;width: 100%;height: 100%;background-color: #00000054;top: 0;z-index: 1000;background-image: url(https://pa1.narvii.com/6258/61f5cd5c652efec508ff3c6e10798d26ccef6366_hq.gif);background-repeat: no-repeat;background-position: center;}"); //Add the css. Image optionals and backup https://pastebin.com/raw/zrzN2PUe
const loadingScreen = document.createElement("div"); //Creates and div element
document.body.appendChild(loadingScreen); //Add the loading screen to the html body
async function ResetAllDates() //Creates a function to Reset All Dates
{ //Starts the async ResetAllDates function
loadingScreen.classList.add("loading"); //Starts the Loading Screen
document.querySelector("#ResetAllDatesVar").textContent = 'Done!'; //Changes the button text
if (IsEditPageOpened === true) //Check if the button edit details was opened
{ //Starts the if condition
await getVariables(); //Call and wait the function getVariables
} //Finishes the if condition
document.querySelector("#ResetStartDate").textContent = 'Done!'; //Changes the button text
document.querySelector("#ResetFinishDate").textContent = 'Done!'; //Changes the button text
document.querySelector("#ResetAllDatesVar").remove(); //Removes the now needless button
document.querySelector("#ResetStartDate").remove(); //Removes the now needless button
document.querySelector("#ResetFinishDate").remove(); //Removes the now needless button
const response = await fetch("https://myanimelist.net/ownlist/" + entrytype2 + "/" + entryid + "/edit", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"body": "add_manga%5Bnum_read_chapters%5D=" + manga_read_chapters + "&add_manga%5Bnum_retail_volumes%5D=" + manga_retail + "&add_manga%5Bnum_read_times%5D=" + manga_read_times + "&add_manga%5Breread_value%5D=" + manga_reread_value + "&add_manga%5Bnum_read_volumes%5D=" + manga_read_volumes + "&add_" + entrytype2 + "%5Bstatus%5D=" + status + "&add_anime%5Bnum_watched_episodes%5D=" + watched_eps + "&add_" + entrytype2 + "%5Bscore%5D=" + current_score + "&add_" + entrytype2 + "%5Btags%5D=" + anime_tags + "&add_" + entrytype2 + "%5Bpriority%5D=" + priority + "&add_" + entrytype2 + "%5Bstorage_type%5D=" + storage_type + "&add_anime%5Bstorage_value%5D=" + storage_value + "&add_anime%5Bnum_watched_times%5D=" + rewatched_times + "&add_anime%5Brewatch_value%5D=" + rewatch_value + "&add_" + entrytype2 + "%5Bcomments%5D=" + comments + "&add_" + entrytype2 + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + entrytype2 + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token + "",
"method": "POST"
}); //Finishes the fetch
loadingScreen.classList.remove("loading"); //Disable the Loading Screen
} //Finishes the async ResetAllDates function
if (AddedToList === true) //If the manga is already added to the the user list
{ //Starts the if condition
document.querySelector("input.inputButton.btn-middle.flat.js-anime-update-button").nextElementSibling.onclick = function() { //Adds an advent listener to the button
IsEditPageOpened = true; //Set the variable to true
}; //Finishes the advent listener
document.querySelector("input.inputButton.btn-middle.flat.js-anime-update-button").nextElementSibling.oncontextmenu = function() { //Adds an advent listener to the button
IsEditPageOpened = true; //Set the variable to true
}; //Finishes the advent listener
} //Finishes the if condition
async function ResetStartDateFunc() //Creates a function to reset the start dates
{ //Starts the async ResetStartDateFunc function
loadingScreen.classList.add("loading"); //Starts the Loading Screen
document.querySelector("#ResetStartDate").textContent = 'Done!'; //Changes the button text
if (document.querySelector("#ResetAllDatesVar") !== null) //Check if the button ResetAllDatesVar exists
{ //Starts the if condition
document.querySelectorAll("#ResetAllDatesVar")[0].textContent = 'Done!'; //Changes the button text
} //Finishes the if condition
if (IsEditPageOpened === true) //Check if the button edit details was opened
{ //Starts the if condition
await getVariables(); //Call and wait the function getVariables
} //Finishes the if condition
document.querySelector("#ResetStartDate").remove(); //Removes the now needless button
if (document.querySelector("#ResetAllDatesVar") !== null) //Check if the button ResetAllDatesVar exists
{ //Starts the if condition
document.querySelector("#ResetAllDatesVar").remove(); //Removes the now needless button
} //Finishes the if condition
const response = await fetch("https://myanimelist.net/ownlist/" + entrytype2 + "/" + entryid + "/edit", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"body": "add_manga%5Bnum_read_chapters%5D=" + manga_read_chapters + "&add_manga%5Bnum_retail_volumes%5D=" + manga_retail + "&add_manga%5Bnum_read_times%5D=" + manga_read_times + "&add_manga%5Breread_value%5D=" + manga_reread_value + "&add_manga%5Bnum_read_volumes%5D=" + manga_read_volumes + "&add_" + entrytype2 + "%5Bstatus%5D=" + status + "&add_anime%5Bnum_watched_episodes%5D=" + watched_eps + "&add_" + entrytype2 + "%5Bscore%5D=" + current_score + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bmonth%5D=" + finish_month + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bday%5D=" + finish_day + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Byear%5D=" + finish_year + "&add_" + entrytype2 + "%5Btags%5D=" + anime_tags + "&add_" + entrytype2 + "%5Bpriority%5D=" + priority + "&add_" + entrytype2 + "%5Bstorage_type%5D=" + storage_type + "&add_anime%5Bstorage_value%5D=" + storage_value + "&add_anime%5Bnum_watched_times%5D=" + rewatched_times + "&add_anime%5Brewatch_value%5D=" + rewatch_value + "&add_" + entrytype2 + "%5Bcomments%5D=" + comments + "&add_" + entrytype2 + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + entrytype2 + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token + "",
"method": "POST"
}); //Finishes the fetch
start_day = ''; //Update the variable start day to null
start_month = ''; //Update the variable start month to null
start_year = ''; //Update the variable start year to null
await ShowButtons(); //Call and wait the function ShowButtons to Display the buttons
loadingScreen.classList.remove("loading"); //Disable the Loading Screen
} //Finishes the async ResetStartDateFunc function
async function ResetFinishDateFunc() //Creates a function to reset the finish dates
{ //Starts the async ResetFinishDateFunc function
loadingScreen.classList.add("loading"); //Starts the Loading Screen
document.querySelector("#ResetFinishDate").textContent = 'Done!'; //Changes the button text
if (document.querySelector("#ResetAllDatesVar") !== null) //Check if the button ResetAllDatesVar exists
{ //Starts the if condition
document.querySelectorAll("#ResetAllDatesVar")[0].textContent = 'Done!'; //Changes the button text
} //Finishes the if condition
if (IsEditPageOpened === true) //Check if the button edit details was opened
{ //Starts the if condition
await getVariables(); //Call and wait the function getVariables
} //Finishes the if condition
document.querySelector("#ResetFinishDate").remove(); //Removes the now needless button
if (document.querySelector("#ResetAllDatesVar") !== null) //Check if the button ResetAllDatesVar exists
{ //Starts the if condition
document.querySelector("#ResetAllDatesVar").remove(); //Removes the now needless button
} //Finishes the if condition
const response = await fetch("https://myanimelist.net/ownlist/" + entrytype2 + "/" + entryid + "/edit", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"body": "add_manga%5Bnum_read_chapters%5D=" + manga_read_chapters + "&add_manga%5Bnum_retail_volumes%5D=" + manga_retail + "&add_manga%5Bnum_read_times%5D=" + manga_read_times + "&add_manga%5Breread_value%5D=" + manga_reread_value + "&add_manga%5Bnum_read_volumes%5D=" + manga_read_volumes + "&add_" + entrytype2 + "%5Bstatus%5D=" + status + "&add_anime%5Bnum_watched_episodes%5D=" + watched_eps + "&add_" + entrytype2 + "%5Bscore%5D=" + current_score + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bmonth%5D=" + start_month + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bday%5D=" + start_day + "&add_" + entrytype2 + "%5Bstart_date%5D%5Byear%5D=" + start_year + "&add_" + entrytype2 + "%5Btags%5D=" + anime_tags + "&add_" + entrytype2 + "%5Bpriority%5D=" + priority + "&add_" + entrytype2 + "%5Bstorage_type%5D=" + storage_type + "&add_anime%5Bstorage_value%5D=" + storage_value + "&add_anime%5Bnum_watched_times%5D=" + rewatched_times + "&add_anime%5Brewatch_value%5D=" + rewatch_value + "&add_" + entrytype2 + "%5Bcomments%5D=" + comments + "&add_" + entrytype2 + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + entrytype2 + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token + "",
"method": "POST"
}); //Finishes the fetch
finish_day = ''; //Update the variable finish day to null
finish_month = ''; //Update the variable finish month to null
finish_year = ''; //Update the variable finish year to null
await ShowButtons(); //Call and wait the function ShowButtons to Display the buttons
loadingScreen.classList.remove("loading"); //Disable the Loading Screen
} //Finishes the async ResetFinishDateFunc function
async function AddStartDate() //Add The Start Date When Watching Is Selected
{ //Starts the async function
loadingScreen.classList.add("loading"); //Starts the Loading Screen
if (IsEditPageOpened === true) //Check if the button edit details was opened
{ //Starts the if condition
await getVariables(); //Call and wait the function getVariables
} //Finishes the if condition
if ((start_month === "") && (start_day === "") && (start_year === "")) // If month and date and year is NOT set in the started dates then Add The Start Date
{ //Starts the if condition
const response = await fetch("https://myanimelist.net/ownlist/" + entrytype2 + "/" + entryid + "/edit", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"body": "add_manga%5Bnum_read_chapters%5D=" + manga_read_chapters + "&add_manga%5Bnum_retail_volumes%5D=" + manga_retail + "&add_manga%5Bnum_read_times%5D=" + manga_read_times + "&add_manga%5Breread_value%5D=" + manga_reread_value + "&add_manga%5Bnum_read_volumes%5D=" + manga_read_volumes + "&add_" + entrytype2 + "%5Bstatus%5D=1&add_anime%5Bnum_watched_episodes%5D=" + watched_eps + "&add_" + entrytype2 + "%5Bscore%5D=" + current_score + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bmonth%5D=" + month + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bday%5D=" + day + "&add_" + entrytype2 + "%5Bstart_date%5D%5Byear%5D=" + year + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bmonth%5D=" + finish_month + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bday%5D=" + finish_day + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Byear%5D=" + finish_year + "&add_" + entrytype2 + "%5Btags%5D=" + anime_tags + "&add_" + entrytype2 + "%5Bpriority%5D=" + priority + "&add_" + entrytype2 + "%5Bstorage_type%5D=" + storage_type + "&add_anime%5Bstorage_value%5D=" + storage_value + "&add_anime%5Bnum_watched_times%5D=" + rewatched_times + "&add_anime%5Brewatch_value%5D=" + rewatch_value + "&add_" + entrytype2 + "%5Bcomments%5D=" + comments + "&add_" + entrytype2 + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + entrytype2 + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token + "",
"method": "POST",
}); //Set The Anime Start Dates
start_day = day; //Update the variable start day to have the actual day
start_month = month; //Update the variable start month to have the actual month
start_year = year; //Update the variable start year to have the actual year
await ShowButtons(); //Call and wait the function ShowButtons to Display the Finished Date and Display the Reset All Dates
} //Finishes the if condition
loadingScreen.classList.remove("loading"); //Disable the Loading Screen
} //Finishes the async AddStartDate function
async function AddFinishDate() //Add The Finished Date When Completed Is Selected
{ //Starts the async AddFinishDate function
loadingScreen.classList.add("loading"); //Starts the Loading Screen
if (IsEditPageOpened === true) //Check if the button edit details was opened
{ //Starts the if condition
await getVariables(); //Call and wait the function getVariables
} //Finishes the if condition
if (finish_month === "" && finish_day === "" && finish_year === "") // If month and date and year is NOT set in the finished dates then Add The Finished Date
{ //Starts the if condition
if ((start_month === "") && (start_day === "") && (start_year === "")) //If month, date and year isn't set in the started dates, add the start date as well
{ //Starts the if condition
start_day = day; //Instead of adding a blank or the actual start day value, add today's day
start_month = month; //Instead of adding a blank or the actual start month value, add today's month
start_year = year; //Instead of adding a blank or the actual start year value, add today's year
} //Finishes the if condition
const response = await fetch("https://myanimelist.net/ownlist/" + entrytype2 + "/" + entryid + "/edit", {
"headers": {
"content-type": "application/x-www-form-urlencoded"
},
"body": "add_manga%5Bnum_read_chapters%5D=" + totalChaps + "&add_manga%5Bnum_retail_volumes%5D=" + manga_retail + "&add_manga%5Bnum_read_times%5D=" + manga_read_times + "&add_manga%5Breread_value%5D=" + manga_reread_value + "&add_manga%5Bnum_read_volumes%5D=" + totalVols + "&add_" + entrytype2 + "%5Bstatus%5D=2&add_anime%5Bnum_watched_episodes%5D=" + totaleps + "&add_" + entrytype2 + "%5Bscore%5D=" + current_score + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bmonth%5D=" + start_month + "&add_" + entrytype2 + "%5Bstart_date%5D%5Bday%5D=" + start_day + "&add_" + entrytype2 + "%5Bstart_date%5D%5Byear%5D=" + start_year + "&add_" + entrytype2 + "%5Btags%5D=" + anime_tags + "&add_" + entrytype2 + "%5Bpriority%5D=" + priority + "&add_" + entrytype2 + "%5Bstorage_type%5D=" + storage_type + "&add_anime%5Bstorage_value%5D=" + storage_value + "&add_anime%5Bnum_watched_times%5D=" + rewatched_times + "&add_anime%5Brewatch_value%5D=" + rewatch_value + "&add_" + entrytype2 + "%5Bcomments%5D=" + comments + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bmonth%5D=" + month + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Bday%5D=" + day + "&add_" + entrytype2 + "%5Bfinish_date%5D%5Byear%5D=" + year + "&add_" + entrytype2 + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + entrytype2 + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token + "",
"method": "POST"
}); //Finishes the fetch
finish_day = day; //Update the variable finish day to have the actual day
finish_month = month; //Update the variable finish month to have the actual month
finish_year = year; //Update the variable finish year to have the actual year
await ShowButtons(); //Call and wait the function ShowButtons to Display the Finished Date and Display the Reset All Dates
} //Finishes the if condition
loadingScreen.classList.remove("loading"); //Disable the Loading Screen
} //Finishes the async AddFinishDate function
function SelectedValue() //Creates a function to get the selected value
{ //Starts the SelectedValue function
if (this.value === '2') //Completed Was Selected
{ //Starts the if condition
AddFinishDate(); //Starts the function AddFinishDate
} //Finishes the Completed else function
else if (this.value === '1') //Watching Was Selected
{ //Starts the if condition
AddStartDate(); //Starts the function set the date
} //Finishes the Watching if function
else if (this.value === '3') //On-Hold Was Selected
{ //Starts the else condition
console.log('On-Hold Was Selected'); //Just shows a message on the dev console, this allows MAL to run their actual advent listener
} //Finishes the On-Hold else function
else if (this.value === '4') //Dropped Was Selected
{ //Starts the else condition
console.log('Dropped Was Selected'); //Just shows a message on the dev console, this allows MAL to run their actual advent listener
} //Finishes the Dropped else function
else //Plan To Watch Was Selected
{ //Starts the else condition
console.log('Plan To Watch Was Selected'); //Just shows a message on the dev console, this allows MAL to run their actual advent listener
} //Finishes the Plan To else function
} //Finishes the SelectedValue function
document.querySelectorAll("#myinfo_status")[1].addEventListener('change', SelectedValue, false); //Adds an advent listener to the status button on the right side of the anime image
document.querySelectorAll("#myinfo_status")[0].addEventListener('change', SelectedValue, false); //Adds an advent listener to the status button below the anime image
if (entrytype2 === 'anime') //If the script is running on an anime entry
{ //Starts the if condition
function PlusButtonAddFinishedDate() //Adding all episodes auto set entry as completed and auto set finished dates
{ //Starts the function PlusButtonAddFinishedDate
if (document.querySelector("#myinfo_watchedeps").value === document.querySelector("#curEps").textContent) //If the number of add eps is the same as the total then
{ //Starts the if condition
document.querySelectorAll("#myinfo_status")[1].value = '2'; //Set the anime as completed, in a way that the user can see
document.querySelectorAll("#myinfo_status")[0].value = '2'; //Set the anime as completed, in a way that the user can see
document.querySelectorAll("#myinfo_status")[1].dataset.class = 'completed'; //Change the selection box to blue
AddFinishDate(); //Call the function AddFinishDate
} //Finishes the if condition
} //Finishes the function PlusButtonAddFinishedDate
function CallPlusButtonAddFinishedDate() //Function to call the function PlusButtonAddFinishedDate after some time
{
setTimeout(PlusButtonAddFinishedDate, 700); //Call the function PlusButtonAddFinishedDate, after 0.5 secs
} //Finishes the function CallPlusButtonAddFinishedDate
document.querySelectorAll("i.fa.fa-plus-circle")[0].addEventListener('click', CallPlusButtonAddFinishedDate, false); //Adds an advent listener to the plus button below the anime image
if (AddedToList === true) //If the entry is already on the user list
{ //Starts the if condition
document.querySelectorAll("i.fa.fa-plus-circle")[1].addEventListener('click', CallPlusButtonAddFinishedDate, false); //Adds an advent listener to the plus button on the right side of the anime image
} //Finishes the if condition
} //Finishes the if condition
} //Finishes the else condition
})();