Load the next page automatically and endlessly. You just need to scroll down to the page bottom. Now there's no need to click on the "next page" button ever again!
当前为
// ==UserScript==
// @name Endless Search/Genre Pages On MAL
// @description Load the next page automatically and endlessly. You just need to scroll down to the page bottom. Now there's no need to click on the "next page" button ever again!
// @author hacker09
// @namespace Endless MAL
// @include https://myanimelist.net/anime.php?*
// @include https://myanimelist.net/manga.php?*
// @include https://myanimelist.net/anime/genre/*
// @include https://myanimelist.net/manga/genre/*
// @run-at document-end
// @version 0.0.1
// ==/UserScript==
(function() {
'use strict';
var newDocument;
if ((window.location.pathname.split('/')[1] === 'anime.php' || window.location.pathname.split('/')[1] === 'manga.php') && (document.querySelector("div.js-categories-seasonal.js-block-list.list") !== null))
{
var nextpagenum = 0;
var increaseby = 50;
var fetchpage = location.href+'&show=';
}
else
{
var nextpagenum = 1;
var increaseby = 1;
var fetchpage = location.href+'?page=';
}
async function requestNextPage() //Creates a function to get the next page
{ //Starts the function
nextpagenum += increaseby;
const response = await fetch(fetchpage+nextpagenum); //Fetch
const html = await response.text(); //Gets the fetch response
const newDocument = new DOMParser().parseFromString(html, 'text/html'); //Parses the fetch response
if ((window.location.pathname.split('/')[1] === 'anime.php' || window.location.pathname.split('/')[1] === 'manga.php') && (document.querySelector("div.js-categories-seasonal.js-block-list.list") !== null))
{
const nextpage = newDocument.querySelector("div.js-categories-seasonal.js-block-list.list");
document.querySelector("div.js-categories-seasonal.js-block-list.list").append(nextpage);
}
else
{
const nextpage = newDocument.querySelector("div.ml8.mr8.mt8.mb16.js-block-list.list > table > tbody");
document.querySelector("table.msh_highlight_parent").append(nextpage);
}
} //Finishes the async requestNextPage function
window.onscroll = async function() {
if ($(window).scrollTop() + $(window).height() == $(document).height()) {
await requestNextPage();
}
};
})();