Endless Search Pages On MAL

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!

目前為 2020-09-07 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name            Endless Search 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!
// @version         0.0.2
// @author          hacker09
// @namespace       Endless MAL
// @include         https://myanimelist.net/featured*
// @include         https://myanimelist.net/clubs.php*
// @include         https://myanimelist.net/anime.php?*
// @include         https://myanimelist.net/manga.php?*
// @include         https://myanimelist.net/people.php*
// @include         https://myanimelist.net/reviews.php*
// @include         https://myanimelist.net/topanime.php*
// @include         https://myanimelist.net/topmanga.php*
// @include         https://myanimelist.net/anime/genre/*
// @include         https://myanimelist.net/manga/genre/*
// @include         https://myanimelist.net/character.php*
// @include         https://myanimelist.net/forum/?board=*
// @include         https://myanimelist.net/forum/?clubid=*
// @include         https://myanimelist.net/anime/producer/*
// @include         https://myanimelist.net/watch/promotion*
// @include         https://myanimelist.net/users.php?cat=user&q=*
// @include         https://myanimelist.net/recommendations.php?s=recentrecs&t=*
// @exclude         https://myanimelist.net/clubs.php?cid=*
// @exclude         https://myanimelist.net/clubs.php?action=*
// @exclude         https://myanimelist.net/watch/promotion/popular
// @exclude         https://myanimelist.net/reviews.php?st=mosthelpful
// @run-at          document-end
// ==/UserScript==

(function() {
  'use strict';
  var nextpage;
  var pagenum = 1;
  var increaseby = 1;
  var nextpagenum = 1;
  var page = '&show=';
  var callFunction = true;
  var pagenumincreaseby = 1;
  var url = window.location.pathname.split('/');
  var numberofthenextpage = document.createElement("center");

  numberofthenextpage.setAttribute("style", "font-size:14px;");
  if (document.querySelector('div.mauto.clearfix.pt24') !== null) document.querySelector('div.mauto.clearfix.pt24').style.width = null;

  if (url[1] === 'users.php')(increaseby = 24, nextpagenum = 0);
  if (url[2] === 'genre' || url[2] === 'producer') page = '?page=';
  if (url[1] === 'recommendations.php')(increaseby = 100, nextpagenum = 0);
  if (url[1] === 'character.php' || url[1] === 'people.php' && location.href.match("\\?letter=") !== null)(increaseby = 50, nextpagenum = 0);
  if (url[1] === 'topanime.php' || url[1] === 'topmanga.php' && location.href.match("type") !== null)(page = '&limit=', increaseby = 50, nextpagenum = 0);
  if (location.href === "https://myanimelist.net/featured" || location.href === "https://myanimelist.net/clubs.php" || url[2] === 'promotion') page = '?p=';
  if (url[1] === 'anime.php' || url[1] === 'manga.php' || location.href.match("clubid=") !== null || location.href.match("forum/\\?board=") !== null)(increaseby = 50, nextpagenum = 0);
  if (location.href.match("featured/search") !== null || location.href.match("clubs.php\\?sort=") !== null || location.href.match("clubs.php\\?cat=") !== null || url[1] === 'reviews.php') page = '&p=';
  if (location.href === "https://myanimelist.net/topanime.php" || location.href === "https://myanimelist.net/topmanga.php" || location.href === "https://myanimelist.net/character.php" || location.href === "https://myanimelist.net/people.php")(page = '?limit=', increaseby = 50, nextpagenum = 0);
  var fetchpage = location.href + page;

  async function requestNextPage() //Creates a function to get the next page
  { //Starts the function
    nextpagenum += increaseby;
    pagenum += pagenumincreaseby;
    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

    numberofthenextpage.innerHTML = '■■■■■■■■■■■■■■■■■■■■■■■■■■■■Page ' + pagenum + ' ⬇️■■■■■■■■■■■■■■■■■■■■■■■■■■■■';

    if (url[1] === 'recommendations.php') {
      document.querySelector('div.mauto.clearfix.pt24').append(numberofthenextpage);
      nextpage = newDocument.querySelector('div#horiznav_nav').nextElementSibling;
      document.querySelector('div.mauto.clearfix.pt24').append(nextpage);
    }
    if (url[2] === 'promotion') {
      document.querySelector('div.pagination.pagination-numbers.di-b.ac').append(numberofthenextpage);
      nextpage = newDocument.querySelector('div.watch-anime-list.watch-video.ml12.clearfix');
      document.querySelector('div.pagination.pagination-numbers.di-b.ac').append(nextpage);
    }
    if (url[1] === 'users.php') {
      document.querySelectorAll('div.spaceit')[1].append(numberofthenextpage);
      nextpage = newDocument.querySelectorAll('table')[1];
      document.querySelectorAll('div.spaceit')[1].append(nextpage);
    }
    if (url[1] === 'reviews.php') {
      document.querySelector('div.mauto.clearfix.pt24').append(numberofthenextpage);
      nextpage = newDocument.querySelector('div#content');
      nextpage.querySelector('div.breadcrumb').remove();
      nextpage.querySelector('div#horiznav_nav').remove();
      document.querySelector('div.mauto.clearfix.pt24').append(nextpage);
    }
    if (url[1] === 'featured') {
      document.querySelector('div.news-list').append(numberofthenextpage);
      nextpage = newDocument.querySelector('div.news-list');
      document.querySelector('div.news-list').append(nextpage);
    }
    if (url[1] === 'anime.php' || url[1] === 'manga.php' || url[2] === 'genre' || url[2] === 'producer') {
      document.querySelector("[class*='js-block-list']").append(numberofthenextpage);
      nextpage = newDocument.querySelector("[class*='js-block-list']");
      document.querySelector("[class*='js-block-list']").append(nextpage);
    }
    if (url[1] === 'clubs.php' || url[1] === 'topanime.php' || url[1] === 'topmanga.php' || url[1] === 'character.php' || url[1] === 'people.php' || location.href.match("clubid=") !== null || location.href.match("forum/\\?board=") !== null) {
      document.querySelector('div.mauto.clearfix.pt24').append(numberofthenextpage);
      nextpage = newDocument.querySelector('table');
      document.querySelector('div.mauto.clearfix.pt24').append(nextpage);
    }
  } //Finishes the async function

  window.onscroll = async function() {
    if (callFunction && window.scrollY * 1.1 >= document.querySelector('div#myanimelist').offsetHeight - window.innerHeight) {
      callFunction = false;
      await requestNextPage();
      setTimeout(function() {
        callFunction = true;
      }, 700);
    }
  };
})();