MangagunDownloader

Manga downloader for mangagun.com

当前为 2022-12-03 提交的版本,查看 最新版本

// ==UserScript==
// @name         MangagunDownloader
// @namespace    https://mangagun.com/
// @version      0.2
// @description  Manga downloader for mangagun.com
// @homepage     https://github.com/Timesient/manga-download-scripts
// @author       Timesient
// @license      GPL-3.0
// @match        https://mangagun.com/read-*
// @require      https://unpkg.com/[email protected]/dist/axios.min.js
// @require      https://unpkg.com/[email protected]/dist/jszip.min.js
// @require      https://unpkg.com/[email protected]/dist/FileSaver.min.js
// @require      https://gf.qytechs.cn/scripts/451810-imagedownloaderlib/code/ImageDownloaderLib.js?version=1124333
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(async function(axios, JSZip, saveAs, ImageDownloader) {
  'use strict';

  // get title
  const title = window.location.pathname.replace('/read-', '').replace('.html', '');

  // get image urls
  const imageURLs = await new Promise(resolve => {
    const timer = setInterval(() => {
      const urls = [];
      document.querySelectorAll('img.chapter-img').forEach(img => urls.push(img.src));
      if(urls.length !== 0 && urls.every(url => !url.includes('loading'))) {
        console.log(urls);
        resolve(urls);
        clearInterval(timer);
      }
    }, 500);
  });

  // setup ImageDownloader
  ImageDownloader({
    getImagePromises,
    title
  });

  // collect promises of image
  function getImagePromises() {
    return imageURLs.map(url => new Promise(resolve => {
      GM_xmlhttpRequest({
        method: 'GET',
        url: url,
        responseType: 'arraybuffer',
        onload: res => resolve(res.response)
      });
    }));
  }

})(axios, JSZip, saveAs, ImageDownloader);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址