Advertisement
ShaggyZE1

Export List - MAL

Feb 6th, 2023 (edited)
1,836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Export List - MAL
  3. // @namespace    MAL Automatic Anime/Manga List Exporter
  4. // @version      0.6
  5. // @description  This is a tool to easily and quickly generate a list with the titles of what animes/mangas you have and export it or add to logged in account.
  6. // @author       hacker09
  7. // @author       ShaggyZE
  8. // @match        https://myanimelist.net/animelist/*
  9. // @match        https://myanimelist.net/mangalist/*
  10. // @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  11. // @run-at       document-end
  12. // @grant        none
  13. // ==/UserScript==
  14. (function() {
  15.     'use strict';
  16.     var $ = window.jQuery; //Defines That The Symbol $ Is A jQuery
  17.     var exportlistbtn = document.createElement("a"); //Creates an a element
  18.     var username = window.location.pathname.split('/')[2]; //Get the username on the url to use later
  19.     var TotalEntries = 0, TotalReWatchedAnimes, TotalReReadMangas, type, interval, text, totalanimestwo, Condition, NEWStyle; //Make these variables global
  20.     var token = document.head.querySelector("[name='csrf_token']").content; //Get the user csrf token
  21.     const status = location.href.slice(-1); //Stores status number
  22.     window.location.pathname.split('/')[1] === 'animelist' ? (type = 'anime', text = 'Export Animes') : (type = 'manga', text = 'Export Mangas'); //Check If the user on an animelist or not and create some variables
  23.  
  24.     exportlistbtn.setAttribute("id", "exportlistbtn"); //Adds the id exportlistbtn to the a element
  25.     exportlistbtn.setAttribute("style", "cursor: pointer;"); //Set the css for the button
  26.     type === 'anime' ? exportlistbtn.innerHTML = "Export Anime List" : exportlistbtn.innerHTML = "Export Manga List"; //Add the text on the Button
  27.  
  28.     if (document.querySelector("#advanced-options-button") === null) //Checks if the Filters button on the modern list style doesn't exist,if not then the user is using an old classic list style
  29.     { //Starts the if condtion
  30.         document.querySelector("a.table_headerLink").parentElement.appendChild(exportlistbtn); //Defines that the 'Export List' button should appear close to the 'Anime Title' or 'Manga Title' text on the old classic style list.
  31.         exportlistbtn.onclick = function() { //Detects the mouse click on the 'Export List' button
  32.             NEWStyle = false; //Add the value false to the variable NEWStyle
  33.             setTimeout(scrape, 500); //Start the scrape function
  34.         }; //Shows a message in the console for dev purposes, and run the scrape function.Classic list styles doesn't need to be scrolled down.
  35.     } //Finishes the if condition
  36.     else //If the Filters button on the modern list style exists, then the user is using the modern list style
  37.     { //Starts the else condtion
  38.         document.querySelector("#advanced-options-button").parentElement.appendChild(exportlistbtn); //Defines that the 'Export List' button should appear close to the Filter button on the modern style list
  39.         document.body.insertAdjacentHTML('beforeend', '<div id="loadingScreen" style="display: none;z-index: 10001 !important;position: fixed;width: 100%;height: 100%;background-color: #00000054;top: 0;background-image: url(https://pa1.narvii.com/6258/61f5cd5c652efec508ff3c6e10798d26ccef6366_hq.gif);background-repeat: no-repeat;background-position: center;"></div>'); //Add the loading screen to the html body
  40.  
  41.         exportlistbtn.onclick = async function() { //Detects the mouse click on the 'Export List' button
  42.             document.querySelector("#loadingScreen").style.display = ''; //Shows the Loading Screen
  43.             NEWStyle = true; //Add the value true to the variable NEWStyle
  44.             //TotalEntries = prompt("Please enter the Total Entrie on this page", "0"); //Create a variable to hold the Total Completed Entries Number
  45.             //TotalReWatchedAnimes = prompt("Please enter the Total ReWatched Animes", "0"); //Creates a variable to hold the actual TotalReWatchedAnimes value
  46.             //TotalReReadMangas = prompt("Please enter the Total ReRead Mangas", "0"); //Creates a variable to hold the actual TotalReReadMangas value
  47.             //await loadingscreen(); //Start the loading screen function
  48.  
  49.             //if (Condition) //Run the codes below only if the user list has more than 300 entries
  50.             //{ //Starts the if condition
  51.             //console.log('Scrolling Down. Please Wait!'); //Shows a message in the console for dev purposes
  52.             //interval = setInterval(function() { //Starts the Function that automatically "Press the keyboard key End"
  53.             //if (document.querySelectorAll("td.data.number").length !== TotalEntries) //If condition that detect if the whole list is loaded or not
  54.             //{ //Starts the if condition
  55.             //window.scrollTo(0, document.body.scrollHeight); //Scrolls the website till the whole list is loaded
  56.             //} //Finishes the if condition
  57.             //else //When the whole list is loaded
  58.             //{ //Starts the else condition
  59.             //console.log('Full List Loaded! Stopping Scrolling Down Now!'); //Shows a message in the console for dev purposes
  60.             //clearInterval(interval); //Breaks the timer that scrolls the page down every 0 secs
  61.             scrape(); //Run the Scrapping Function
  62.             //} //Finishes the else condition
  63.             //}, 0); //Finishes the interval function that will run the function every 0 secs
  64.             //} //Finishes the if condition
  65.         }; //Finishes the onclick function
  66.     } //Finishes the else condition
  67.  
  68.     async function loadingscreen() //Creates a loading screen function that also checks if the user is on the completed list or not, and get the needed variables
  69.     { //Starts the loadingscreen function
  70.         const loadingScreen = document.createElement("div"); //Creates a div element
  71.         loadingScreen.setAttribute("id", "loadingScreen"); //Adds an id to the element
  72.         loadingScreen.setAttribute("style", "position: fixed;width: 100%;height: 100%;background-color: black;top: 0;z-index: 1000;background-image: url(https://pa1.narvii.com/6258/61f5cd5c652efec508ff3c6e10798d26ccef6366_hq.gif);background-repeat: no-repeat;background-position: center;"); //Set the element css and img
  73.         document.body.appendChild(loadingScreen); //Add the loading screen to the html body
  74.  
  75.         if (NEWStyle) //Run the codes below only if the list is using the new style
  76.         { //Starts the if condition
  77.             if (document.querySelectorAll("td.data.number").length < 300) //Check if the user list has less than 300 entries
  78.             { //Starts the if condition
  79.                 Condition = false; //Add the value false to the var Condition
  80.                 console.log('This user has less than 300 Completed Entries\nFull List is Already Loaded!'); //Shows a message in the console for dev purposes
  81.                 scrape(); //Run the Scrapping Function
  82.             } //Finishes the if condition
  83.             else //If the user list has 300 or more entries
  84.             { //Starts the else condition
  85.                 Condition = true; //Add the value true to the var Condition
  86.                 while (true) { //Starts the while condition to get the Total Number of Entries on the user completed list
  87.                     console.log('This user has more than 300 Completed Entries\nGetting the Total Completed Entries Number...'); //Shows a message in the console for dev purposes
  88.                     if (TotalEntries === document.querySelectorAll("td.data.number").length) //If the next page has less than 300 completed entries stop looping the whlie condition
  89.                     { //Starts the if condition
  90.                         console.log('Finished Getting the Total Completed Entries Number!'); //Shows a message in the console for dev purposes
  91.                         return; //Return whether or not the fetched page has less than 300 completed entries
  92.                     } //Finishes the if condition
  93.                 } //Finishes the while condition
  94.             } //Finishes the else condition
  95.         } //Finishes the if condition
  96.     } //Finishes the loadingscreen function
  97.  
  98.     function scrape() //Function that will scrape the page
  99.     { //Starts the function scrape
  100.         if (isNaN(status) === true) //Checks if status is not a number
  101.         { //Starts the if condition
  102.             alert("Execute this on the every page except the 'All' page with filters clear! \nRedirecting. \nTry again after the page loads."); //Show an error alert message to the user, if the user is not on a valid list
  103.             window.location.replace(window.location.href.split('?')[0] + "?status=1"); //Redirects the user to status = 1
  104.             throw new Error("Redirecting"); //Show an error alert message on the dev console of the user
  105.         } else if (location.href.match('\\?status=7') === true || location.href.match('\\?status=') === null) { //Checks if the user is on the all animes/mangas tab or not
  106.             alert("Execute this on the every page except the 'All' page with filters clear! \nRedirecting. \nTry again after the page loads."); //Show an error alert message to the user, if the user is not on  valid list
  107.             window.location.replace(window.location.href.split('?')[0] + "?status=1"); //Redirects the user to status = 1
  108.             throw new Error("Redirecting"); //Show an error alert message on the dev console of the user
  109.         } //Finishes the if condition
  110.         console.log('Starting To Scrape...Please Wait! ' + status); //Shows a message in the console for dev purposes
  111.         alert('Starting To Scrape...Please Wait! '); //Shows a message to the user
  112.  
  113.         var titles = []; //Creates a blank array to use later
  114.         var rewatches = []; //Creates a blank array to use later
  115.         var scores = []; //Creates a blank array to use later
  116.         var started = []; //Creates a blank array to use later
  117.         var finished = []; //Creates a blank array to use later
  118.         var progress = []; //Creates a blank array to use later
  119.         var progress2 = []; //Creates a blank array to use later
  120.         var chapters = []; //Creates a blank array to use later
  121.         var volumes = []; //Creates a blank array to use later
  122.         var chapters2 = []; //Creates a blank array to use later
  123.         var volumes2 = []; //Creates a blank array to use later
  124.         var notes = []; //Creates a blank array to use later
  125.         var moreLinks = document.querySelectorAll('a'); //Defines a variable named 'moreLinks' that will be used to click on all the more buttons on the completed page
  126.         var titles_old = document.querySelectorAll('div table tbody tr a.animetitle span'); //Select only the anime title on the old style list
  127.         var titles_new = document.querySelectorAll('tbody.list-item tr.list-table-data td.data.title a.link.sort'); //Select only the anime title on the Modern default style list
  128.         var scores_old = document.querySelectorAll('div table tbody tr a.animescore span'); //Select only the anime score on the old style list
  129.         var scores_new = document.querySelectorAll('.score > a > span'); //Select only the anime score on the Modern default style list
  130.         var started_old = document.querySelectorAll('div table tbody tr a.animestarted span'); //Select only the anime started on the old style list
  131.         var started_new = document.querySelectorAll('.started > a > span'); //Select only the anime started on the Modern default style list
  132.         var progress_new = document.querySelectorAll('.progress > div > span > a'); //Select only the anime progress on the Modern default style list
  133.         var progress2_new = document.querySelectorAll('.progress > div > span'); //Select only the anime progress on the Completed Modern default style list
  134.         var chapters_new = document.querySelectorAll('.chapter > div > span > a'); //Select only the manga chapters on the Modern default style list
  135.         var volumes_new = document.querySelectorAll('.volume > div > span > a'); //Select only the manga volumes on the Modern default style list
  136.         var chapters2_new = document.querySelectorAll('.chapter > div > span'); //Select only the manga chapters on the Modern default style list
  137.         var volumes2_new = document.querySelectorAll('.volume > div > span'); //Select only the manga volumes on the Modern default style list
  138.         var old_list = false; //Variable that can be changed latter to the value 'true' if the user used the script on an old classic style list.The value 'false' will be kept if the user used the script on the new modern list style.
  139.  
  140.         if (titles_old.length > titles_new.length) //Checks if the user list style is the old classic style or the new modern style
  141.         { //Starts the if condition
  142.             titles = titles_old; //If the user used the script on an old classic list style, the titles will be added to the titles array
  143.             scores - scores_old;
  144.             started - started_old;
  145.             old_list = true; //Variable old_list will be changed to the value 'true' if the user used the script on an old classic style list
  146.         } //Finishes the if condition
  147.         else //If the user used the script on a new modern list style
  148.         { //Starts the else condition
  149.             for (var i = 0; i < titles_new.length; i++) //This for condition is responsible for getting all the anime data
  150.             { //Starts the for condition
  151.                 titles[i] = titles_new[i].text; //Add all titles to an array
  152.                 scores[i] = scores_new[i]; //Add all scores to an array
  153.                 started[i] = started_new[i]; //Add all started date to an array
  154.                 if (type == "anime") {
  155.                   if (status == 1 || status == 3 || status == 4 || status == 6) { progress[i] = progress_new[i].text; };
  156.                   if (status == 2) { progress2[i] = progress2_new[i].innerHTML; };
  157.                 } else {
  158.                   if (status == 1 || status == 3 || status == 4 || status == 6) { chapters[i] = chapters_new[i].text; volumes[i] = volumes_new[i].text; };
  159.                   if (status == 2) { chapters2[i] = chapters2_new[i].innerHTML; volumes2[i] = volumes2_new[i].innerHTML; };
  160.                 }
  161.             } //Finishes the for condition
  162.         } //Finishes the else condition
  163.  
  164.         if (old_list) //If the script is working on an old classic list style
  165.         { //Starts the if condition
  166.             //The 12 lines below Fetches the rewatch count information bypassing the 'More' link on old classic list styles
  167.             $("div.hide").each(function(index, value) {
  168.                 var series_id = $(value).attr('id').split('more')[1];
  169.                 $.post("/includes/ajax-no-auth.inc.php?t=6", {
  170.                     color: 1,
  171.                     id: series_id,
  172.                     memId: $('#listUserId').val(),
  173.                     type: $('#listType').val()
  174.                 }, function(data) {
  175.                     if (type == "anime") started[index] = $(data.html).find('strong')[0].innerHTML;
  176.                     finished[index] = $(data.html).find('strong')[1].innerHTML; //If the type is anime start scrapping the anime rewatched values
  177.                     if (type == "manga") //If the type is anime start scrapping the manga 'Start Date' values
  178.                     { //Starts the if condition
  179.                         var moreSection = $(data.html).find('td').html(); //Opens the more button on old classic style list
  180.                         var DateIndex = moreSection.indexOf("Start Date"); //Detects date started
  181.                         started[index] = moreSection.charAt(DateIndex + 11);
  182.                         var moreSection1 = $(data.html).find('td').html(); //Opens the more button on old classic style list
  183.                         var DateIndex1 = moreSection1.indexOf("End Date"); //Detects date started
  184.                         finished[index] = moreSection1.charAt(DateIndex1 + 9);
  185.                     } //Finishes the if condition
  186.                 }, "json"); //The scrapping isn't done using HTML,it's done by scrapping only the json file that's loaded when the user goes down (loads more animes/mangas) ('XHR Get' Method)
  187.             }); //Finishes the each condition
  188.         } //Finishes the if condition
  189.         else //If the script was run on a new modern list style
  190.         { //Starts the else condition
  191.             console.log('Opening And Scraping All "More" Buttons.Please Wait!'); //Shows a message in the console for dev purposes
  192.             //The 6 lines Below Will Click all links labeled 'More' to get the rewatch counts later on the page
  193.             for (i = moreLinks.length; i--;) { //Starts the for condition
  194.                 if (moreLinks[i].innerHTML == 'More') { //If the moreLinks variable has the text More
  195.                     moreLinks[i].click(); //Click on the moreLinks button
  196.                 } //Finishes the if condition
  197.             } //Finishes the for condition
  198.         } //Finishes the else condition
  199.  
  200.         document.querySelector("head").innerHTML = "<title>Almost Done...</title>"; //Change the tab title
  201.         console.log('Almost Done...'); //Shows a message on the console for dev purposes
  202.  
  203.         wait(); //Repeats every 1 second until all More-sections are processed
  204.  
  205.         function formatDate(userDate) {
  206.             //console.log(userDate);
  207.             // split date string at '/'
  208.             var dateArr = userDate.split(' ');
  209.             var dateArr2 = dateArr[1].split(',')
  210.             //test results of split
  211.             //console.log(dateArr[0]);
  212.             //console.log(dateArr2[1]);
  213.             //console.log(dateArr2[2]);
  214.             // check for single number day or month
  215.             // prepend '0' to single number day or month
  216.             if (dateArr[0].length == 1) {
  217.                 dateArr[0] = '0' + dateArr[0];
  218.             } else if (dateArr[1].length == 1) {
  219.                 dateArr[1] = '0' + dateArr[1];
  220.             }
  221.             // concatenate new values into one string
  222.             userDate = dateArr[0] + dateArr[1] + dateArr[2];
  223.             // test new string value
  224.             //console.log(userDate);
  225.             // return value
  226.             return userDate;
  227.         }
  228.  
  229.         async function AddEntry(id, current_score, manga_read_chapters, manga_read_volumes, watched_eps, comments) //Creates a function to Score + set as "Watching" the Franchise
  230.         { //Starts the function
  231.             var current_score1 = current_score.replace("-", "0")
  232.             if (type == "anime") {
  233.               var watched_eps1 = watched_eps.replace("-", "0")
  234.             } else {
  235.               var manga_read_chapters1 = manga_read_chapters.replace("-", "0")
  236.               var manga_read_volumes1 = manga_read_volumes.replace("-", "0")
  237.             }
  238.             if (type == "anime") {
  239.               const response = await fetch("https://myanimelist.net/ownlist/" + type + "/add.json", { //Fetches the page
  240.                   "headers": {
  241.                       "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  242.                   },
  243.                   "body": "{\"" + type + "_id" + "\":" + id + ",\"status\":" + status + ",\"score\":" + current_score1 + ",\"num_watched_episodes\":" + watched_eps1 + ",\"comments\":\"" + comments + "\",\"csrf_token\":\"" + token + "\"}",
  244.                   "method": "POST"
  245.               }); //Finishes the fetch
  246.               const response0 = await fetch("https://myanimelist.net/ownlist/" + type + "/edit.json", { //Fetches the page
  247.                   "headers": {
  248.                       "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  249.                   },
  250.                   "body": "{\"" + type + "_id" + "\":" + id + ",\"status\":" + status + ",\"score\":" + current_score1 + ",\"num_watched_episodes\":" + watched_eps1 + ",\"comments\":\"" + comments + "\",\"csrf_token\":\"" + token + "\"}",
  251.                   "method": "POST"
  252.               }); //Finishes the fetch
  253.             } else {
  254.               const response1 = await fetch("https://myanimelist.net/ownlist/" + type + "/add.json", { //Fetches the page
  255.                   "headers": {
  256.                       "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  257.                   },
  258.                   "body": "{\"" + type + "_id" + "\":" + id + ",\"status\":" + status + ",\"score\":" + current_score + ",\"num_read_chapters\":" + manga_read_chapters1 + ",\"num_read_volumes\":" + manga_read_volumes1 + ",\"comments\":\"" + comments + "\",\"csrf_token\":\"" + token + "\"}",
  259.                   "method": "POST"
  260.               }); //Finishes the fetch
  261.               const response2 = await fetch("https://myanimelist.net/ownlist/" + type + "/edit.json", { //Fetches the page
  262.                   "headers": {
  263.                       "content-type": "application/x-www-form-urlencoded; charset=UTF-8"
  264.                   },
  265.                   "body": "{\"" + type + "_id" + "\":" + id + ",\"status\":" + status + ",\"score\":" + current_score + ",\"num_read_chapters\":" + manga_read_chapters1 + ",\"num_read_volumes\":" + manga_read_volumes1 + ",\"comments\":\"" + comments + "\",\"csrf_token\":\"" + token + "\"}",
  266.                   "method": "POST"
  267.               }); //Finishes the fetch
  268.             }
  269.  
  270.  
  271.         } //Finishes the async function
  272.  
  273.         async function AddEntry2(id, manga_read_chapters, manga_retail, manga_read_times, manga_reread_value, manga_read_volumes, watched_eps, current_score, month, day, year, finish_month, finish_day, finish_year, anime_tags, priority, storage_type, storage_value, rewatched_times, rewatch_value, comments, is_asked_to_discuss, sns_post_type) //Creates a function to edit entry
  274.         { //Starts the function AddEntry
  275.             const response = await fetch("https://myanimelist.net/ownlist/" + type + "/" + id + "/edit", {
  276.                 "headers": {
  277.                     "content-type": "application/x-www-form-urlencoded"
  278.                 },
  279.                 "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_" + type + "%5Bstatus%5D=1&add_anime%5Bnum_watched_episodes%5D=" + watched_eps + "&add_" + type + "%5Bscore%5D=" + current_score + "&add_" + type + "%5Bstart_date%5D%5Bmonth%5D=" + month + "&add_" + type + "%5Bstart_date%5D%5Bday%5D=" + day + "&add_" + type + "%5Bstart_date%5D%5Byear%5D=" + year + "&add_" + type + "%5Bfinish_date%5D%5Bmonth%5D=" + finish_month + "&add_" + type + "%5Bfinish_date%5D%5Bday%5D=" + finish_day + "&add_" + type + "%5Bfinish_date%5D%5Byear%5D=" + finish_year + "&add_" + type + "%5Btags%5D=" + anime_tags + "&add_" + type + "%5Bpriority%5D=" + priority + "&add_" + type + "%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_" + type + "%5Bcomments%5D=" + comments + "&add_" + type + "%5Bis_asked_to_discuss%5D=" + is_asked_to_discuss + "&add_" + type + "%5Bsns_post_type%5D=" + sns_post_type + "&csrf_token=" + token,
  280.                 "method": "POST",
  281.             }); //Finishes the fetch
  282.         }
  283.  
  284.         function wait() //Creates the wait function
  285.         { //Starts the function wait
  286.             if (type == "manga" && document.querySelector("#advanced-options-button") !== null) //If the list type is manga and it's using the Modern Style
  287.             { //Starts the if condition
  288.                 for (var i = document.querySelectorAll("td.td1.borderRBL").length; i--;) { //For condition to make the started values bold, otherwise the script won't detect started Mangas
  289.                     document.querySelectorAll("td.td1.borderRBL")[i].outerHTML = "<strong>" + document.querySelectorAll("td > br:nth-last-of-type(9)")[i].nextSibling.textContent.replace("Start Date:", "") + "</strong><strong>" + document.querySelectorAll("td > br:nth-last-of-type(8)")[i].nextSibling.textContent.replace("End Date:", "") + "</strong><strong>" + document.querySelectorAll("td > br:nth-last-of-type(2)")[i].nextSibling.textContent.replace("Notes:", "") + "</strong>"; //Make the Date values bold
  290.                 } //Finishes the for condition
  291.             } else { //Starts the if condition
  292.                 for (var j = document.querySelectorAll("td.td1.borderRBL").length; j--;) { //For condition to make the started values bold, otherwise the script won't detect started Mangas
  293.                     document.querySelectorAll("td.td1.borderRBL")[j].outerHTML = "<strong>" + document.querySelectorAll("td > br:nth-last-of-type(7)")[j].nextSibling.textContent.replace("Start Date:", "") + "</strong><strong>" + document.querySelectorAll("td > br:nth-last-of-type(6)")[j].nextSibling.textContent.replace("End Date:", "") + "</strong><strong>" + document.querySelectorAll("td > br:nth-last-of-type(2)")[j].nextSibling.textContent.replace("Notes:", "") + "</strong>"; //Make the Date values bold
  294.                 } //Finishes the for condition
  295.             }
  296.             setTimeout(function() //Creates the timeout function
  297.                 { //Starts the timeout function
  298.                     started = document.querySelectorAll('tbody.list-item tr.more-info strong:nth-child(1)');
  299.                     finished = document.querySelectorAll('tbody.list-item tr.more-info strong:nth-child(2)');
  300.                     notes = document.querySelectorAll('tbody.list-item tr.more-info strong:nth-child(3)'); //If the script was run on an new modern list style then use this command to set the variable started
  301.                     if (started.length != titles.length) //Check if All sections were or not opened
  302.                     { //Starts the if condition
  303.                         wait(); //If All sections were not opened check it again after 2 seconds
  304.                     } //Finishes the if condition
  305.                     else //If All sections were opened
  306.                     { //Starts the else condition
  307.                         if (old_list) //Check if the script was run in an old classic list style or not
  308.                         { //Starts the if condition
  309.                             for (var i = 0; i < titles.length; i++) {
  310.                                 AddEntry(titles[i].parentElement.href.match(/\d+/)[0], "0", "0", "0", progress[i], notes[i].innerHTML.replace("&nbsp;", "").trim());
  311.                             } //Finishes the for condition
  312.                         } //Finishes the if condition
  313.                         else //If the script was run in on the new default modern list style
  314.                         { //Starts the else condition
  315.                             for (i = 0; i < titles.length; i++) {
  316.                                 //console.log(started[i].innerHTML);
  317.                                 //console.log(finished[i].innerHTML);
  318.                                 //console.log(notes[i].innerHTML.replace("&nbsp;", ""));
  319.                                 formatDate(started[i].innerHTML);
  320.                                 if (status == 2) { //If the script was run in on the Completed list
  321.                                   AddEntry(titles_new[i].href.match(/\d+/)[0], "0", chapters2[i], volumes2[i], progress2[i], notes[i].innerHTML.replace("&nbsp;", "").trim());
  322.                                 } else {
  323.                                     AddEntry(titles_new[i].href.match(/\d+/)[0], "0", chapters[i], volumes[i], progress[i], notes[i].innerHTML.replace("&nbsp;", "").trim());
  324.                                 } //Finishes the if condition
  325.                                 //AddEntry2(titles_new[i].href.match(/\d+/)[0], "0", "0", "0", "", "0", progress[i], scores[i], "11", "1", "2022", "12", "1", "2023", "", "0", "", "0", "0", "", notes[i].innerHTML.replace("&nbsp;", ""), "0", "0")
  326.  
  327.                             } //Finishes the for condition
  328.                         } //Finishes the else condition
  329.                         document.querySelector("#loadingScreen").style.display = 'none'; //Hides the Loading Screen
  330.                         //document.querySelector("body").innerHTML = ('');
  331.                         window.scrollTo(0, 0); //Scroll the page to the top
  332.                         document.querySelector("head").innerHTML = "<title>Done! List Extracted!.</title>"; //Change the tab title
  333.                         console.log('Done! List Extracted!'); //Shows a message in the console for dev purposes
  334.                         alert("Done! List Extracted!"); //Shows completed message
  335.                         //location.reload()
  336.                     } //Finishes the else condition
  337.                 }, 1000); //Finishes the settimeout function. Wait 1 second
  338.         } //Finishes the function wait
  339.     } //Finishes the scrape function
  340. })(); //Finishes the tampermonkey function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement