Advertisement
Guest User

Untitled

a guest
Feb 8th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       var ChiakiIDSArray = [] //Creates a new blank global array
  2.       var GuideIndexIDS = []; //Creates a new blank global array
  3.  
  4.         var GuideIndexIDSmatches = document.querySelector("div.clearfix.word-break").firstChild.innerText.match(/(?:\|\b\d+)/gi); //Creates a new variable to hold the whole text of the first post on the topic
  5.         var GuideIndexIDS = []; //Creates a new blank array
  6.         var match; //Creates a new blank variable
  7.         for (match in GuideIndexIDSmatches) //For every anime id existent on the GuideIndexIDSmatches text content
  8.         { //Starts the for condition
  9.           GuideIndexIDS.push(GuideIndexIDSmatches[match].replace(/(?:\|)/gi, '')); //Remove the first | symbol in front of the anime id numbers
  10.         } //Finishes the for condition
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.         var ChiakiDocument; //Makes the variable global
  22.         async function GetChiakiIDS() { //Creates a new function
  23.           while (true) { //While the if condition returns true
  24.             var match; //Creates a new blank variable
  25.             var matches = document.querySelector("div.clearfix.word-break").firstChild.innerText.match(/(?:\|\b\d+)/gi); //Get all the anime ids on the MAL page
  26.             for (match in matches) //For all anime ids on the MAL page
  27.             { //Starts the for condition
  28.               var FetchChiaki = matches[match].replace(/(?:\|)/gi, ' https://api.allorigins.win/raw?url=https://chiaki.site/?/tools/watch_order/id/'); //Creates a variable to fetch chiaki.site
  29.               const html = await (await fetch(FetchChiaki)).text(); //Gets the fetch response
  30.               ChiakiDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
  31.  
  32.               for (const ChiakiAnimeIDS of ChiakiDocument.querySelectorAll('span.uk-text-muted.uk-text-small > a')) { //For every anime entry links existent on the chiaki.site
  33.                 ChiakiIDSArray.push(ChiakiAnimeIDS.href.match(/\d+/)[0]); //Get only the anime id of every anime entry links existent on the chiaki.site
  34.               } //Finishes the for condition
  35.             } //Finishes the for condition
  36.             if (ChiakiDocument.body.innerText.search('Watch') > -1) { //If the text Watch was found on the chiaki.site document
  37.               return; //Return true
  38.             } //Finishes the if condition
  39.             await new Promise(resolve => setTimeout(resolve, 1000)); //Wait 1 sec before fetching chiaki.site again
  40.           } //Finishes the while condition
  41.         } //Finishes the async GetChiakiIDS function
  42.         GetChiakiIDS(); //Starts the async GetChiakiIDS function
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.         var FinalArray = ChiakiIDSArray.filter(d => !GuideIndexIDS.includes(d)); //Get the ids that chiaki.site has and the Guide is missing
  54.         var GuideMissingIds = document.createElement("div"); //Creates a div element
  55.         FinalArray.forEach(function(AnimeID) { //For every anime id that the guide index is missing
  56.           GuideMissingIds.innerHTML += GuideMissingIds.innerHTML = '<br><a href="' + `https://myanimelist.net/anime/${AnimeID}` + '">' + `https://myanimelist.net/anime/${AnimeID}` + '</a>'; //Add to the GuideMissingIds div a line break + the anime link with the link as text too
  57.         }); //Finishes the foreach condition
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.         $("b:contains('Guides available:')")[0].appendChild(GuideMissingIds); //Show the links that the Tampermonkey Guide Index is missing
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement