Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var ChiakiIDSArray = [] //Creates a new blank global array
- var GuideIndexIDS = []; //Creates a new blank global array
- 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
- var GuideIndexIDS = []; //Creates a new blank array
- var match; //Creates a new blank variable
- for (match in GuideIndexIDSmatches) //For every anime id existent on the GuideIndexIDSmatches text content
- { //Starts the for condition
- GuideIndexIDS.push(GuideIndexIDSmatches[match].replace(/(?:\|)/gi, '')); //Remove the first | symbol in front of the anime id numbers
- } //Finishes the for condition
- var ChiakiDocument; //Makes the variable global
- async function GetChiakiIDS() { //Creates a new function
- while (true) { //While the if condition returns true
- var match; //Creates a new blank variable
- var matches = document.querySelector("div.clearfix.word-break").firstChild.innerText.match(/(?:\|\b\d+)/gi); //Get all the anime ids on the MAL page
- for (match in matches) //For all anime ids on the MAL page
- { //Starts the for condition
- 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
- const html = await (await fetch(FetchChiaki)).text(); //Gets the fetch response
- ChiakiDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
- for (const ChiakiAnimeIDS of ChiakiDocument.querySelectorAll('span.uk-text-muted.uk-text-small > a')) { //For every anime entry links existent on the chiaki.site
- ChiakiIDSArray.push(ChiakiAnimeIDS.href.match(/\d+/)[0]); //Get only the anime id of every anime entry links existent on the chiaki.site
- } //Finishes the for condition
- } //Finishes the for condition
- if (ChiakiDocument.body.innerText.search('Watch') > -1) { //If the text Watch was found on the chiaki.site document
- return; //Return true
- } //Finishes the if condition
- await new Promise(resolve => setTimeout(resolve, 1000)); //Wait 1 sec before fetching chiaki.site again
- } //Finishes the while condition
- } //Finishes the async GetChiakiIDS function
- GetChiakiIDS(); //Starts the async GetChiakiIDS function
- var FinalArray = ChiakiIDSArray.filter(d => !GuideIndexIDS.includes(d)); //Get the ids that chiaki.site has and the Guide is missing
- var GuideMissingIds = document.createElement("div"); //Creates a div element
- FinalArray.forEach(function(AnimeID) { //For every anime id that the guide index is missing
- 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
- }); //Finishes the foreach condition
- $("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