// ==UserScript== // @name Add new entries to your MyAnimeList - Chiaki // @namespace https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs // @version 7 // @description With a single click add all entries from an entire franchise on any chiaki.site page directly to your MAL account with the status of your choice. // @author hacker09 // @match https://chiaki.site/?/auth // @match https://chiaki.site/?/tools/watch_order/* // @match https://myanimelist.net/dialog/authorization // @icon https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://chiaki.site/&size=64 // @run-at document-end // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; if (location.href.match('chiaki') !== null && document.querySelector('a.uk-button.uk-button-text.uk-text-danger').innerText === 'SIGN IN' && location.href !== 'https://chiaki.site/?/') //If the user is on the chiaki.site and it the user isn't signed in on chiaki.site, and if the user wasn't returned to the chiaki.site home page { //Starts the if condition document.querySelector('a.uk-button.uk-button-text.uk-text-danger').click(); //Click on the sign in btn if (location.href.match('auth') !== null) //If the user is on the auth chiaki.site page { //Starts the if condition document.querySelectorAll('.uk-button-large')[1].click(); //Click on the SIGN IN WITH MYANIMELIST btn } //Finishes the if condition } //Finishes the if condition if (location.href.match('authorization') !== null) //If the user is on the MAL auth website { //Starts the if condition window.onload = function() { //When the page finishes loading setTimeout(function() { if (document.querySelectorAll("form > input")[1].id !== 'clicked') //If the form id is not clicked { //Starts the if condition document.querySelectorAll("form > input")[1].click(); //Click on the Allow btn } //Finishes the if condition }, 300); //Click on the Allow btn }; //Finishes the onload event listener } //Finishes the if condition if (location.href === 'https://chiaki.site/?/') //When the user gets returned to the chiaki.site home page { //Starts the if condition window.history.go(-3); //Return to the franchise page } //Finishes the if condition document.querySelector("ul.uk-flex-center.noborder.uk-tab").insertAdjacentHTML('beforeend', '
  • ADD
  • '); //Show The ADD btn document.querySelector('#AddToMAL').onclick = function(e) { //When the add btn is clicked e.preventDefault(); //Prevent the default click action e.stopPropagation(); //Prevent the default click action var UserInput = prompt('1 Watching\n2 Completed\n3 On-Hold\n4 Dropped\n5 PTW\n*Write only your choice number and click OK'); //Gets the user input switch (UserInput) { //Detect the user choice case '1': //If the user choose option 1 UserInput = 'watching'; //Change the variable value break; //Stop executing the switch statement case '2': //If the user choose option 2 UserInput = 'completed'; //Change the variable value break; //Stop executing the switch statement case '3': //If the user choose option 3 UserInput = 'on_hold'; //Change the variable value break; //Stop executing the switch statement case '4': //If the user choose option 4 UserInput = 'dropped'; //Change the variable value break; //Stop executing the switch statement case '5': //If the user choose option 5 UserInput = 'plan_to_watch'; //Change the variable value break; //Stop executing the switch statement } //Ends the switch statement var Counter = 0; //Create a new counter variable document.querySelectorAll("span.uk-text-muted.uk-text-small > a:nth-child(1)").forEach(async function(el) { //ForEach MAL entry link fetch("https://chiaki.site/?/animelist/update", { //Fetches "headers": { "content-type": "application/x-www-form-urlencoded; charset=UTF-8", }, "body": `id=${el.href.split('/')[4]}&status=${UserInput}`, "method": "POST" }) //Finishes the Fetch .then(response => { //After the fetch finished Counter += 1; //Increase the counter by 1 if (Counter === document.querySelectorAll("span.uk-text-muted.uk-text-small > a:nth-child(1)").length) //If the Counter is equal to the amount of fetched links { //Starts the if condition location.reload(); //Reloads the page after adding is completed } //Finishes the if condition }) //Finishes the then statement }) //Finishes the ForEach loop } //Finishes the onclick event listener })();