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