Advertisement
Guest User

Untitled

a guest
Aug 4th, 2022
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         test
  3. // @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
  4. // @version      2
  5. // @description  test
  6. // @author       hacker09
  7. // @match        https://myanimelist.net/profile/hacker09
  8. // @icon         https://t3.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://myanimelist.net&size=64
  9. // @grant        GM.xmlHttpRequest
  10. // @run-at       document-end
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14.   'use strict';
  15.   var nextpagenum = 0; //Create a variable to hold the page number
  16.   var Counter = 0; //Create a variable to hold the Total Entries Number
  17.   var increaseby = 1000; //Create a variable to Increase the list page number
  18.  
  19.   while (true) { //Starts the while condition to get the Total Number of Entries on the user list
  20.     var entries = GM.xmlHttpRequest({
  21.       responseType: 'json',
  22.       url: `https://api.myanimelist.net/v2/users/${location.href.split('/')[4]}/animelist?fields=list_status&status=${stats}&limit=${nextpagenum}`,
  23.       headers: {
  24.         "x-mal-client-id": "8ef0267fd86a187d479e6fcd7e1bb42a"
  25.       },
  26.       onload: async function(response) {
  27.         console.log(response.response.data)
  28.         //return response.response.data;
  29.       }
  30.     });
  31.  
  32.     var TotalEntries = entries.length; //Save the Total Entries Number
  33.     Counter += TotalEntries; //Sum the Total Entries Number to TotalEntries
  34.     entries.forEach(el => EntryIds.push(el.anime_id)); //Save all entry ids
  35.     if (TotalEntries !== 1000) //If the next page has less than 1000 entries stop looping the while condition
  36.     { //Starts the if condition
  37.       console.log('Finished Getting the Total Entries Number!'); //Shows a console message
  38.       return; //Stop the script if fetched page has less than 1000 entries and run the EntryIds.forEach loop
  39.     } //Finishes the if condition
  40.   } //Finishes the while condition
  41. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement