UrasundayDownloader

Manga downloader for urasunday.com

目前为 2022-12-18 提交的版本。查看 最新版本

// ==UserScript==
// @name         UrasundayDownloader
// @namespace    https://github.com/Timesient/manga-download-scripts
// @version      0.3
// @license      GPL-3.0
// @author       Timesient
// @description  Manga downloader for urasunday.com
// @icon         https://urasunday.com/assets/img/favicon.ico
// @homepageURL  https://gf.qytechs.cn/zh-CN/scripts/451881-urasundaydownloader
// @supportURL   https://github.com/Timesient/manga-download-scripts/issues
// @match        https://urasunday.com/title/*
// @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=1129414
// @grant        GM_xmlhttpRequest
// @grant        GM_info
// ==/UserScript==

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

  // get title
  const title = document.querySelector('body > div.title > div:nth-child(1) > div:nth-child(1)').textContent.trim();

  // get image urls from document
  const urls = await new Promise(resolve => {
    GM_xmlhttpRequest({
      method: 'GET',
      url: window.location.href,
      headers: { 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1' },
      onload: res => resolve(res.response.match(/src: '.*'/gm).map(url => url.split('\'')[1]))
    });
  });

  // setup ImageDownloader
  ImageDownloader.init({
    maxImageAmount: urls.length,
    getImagePromises,
    title,
    positionOptions: { top: '140px' }
  });

  // collect promises of image
  function getImagePromises(startNum, endNum) {
    return urls
      .slice(startNum - 1, endNum)
      .map(url => axios
        .get(url, { responseType: 'arraybuffer' })
        .then(res => res.data)
        .then(ImageDownloader.fulfillHandler)
        .catch(ImageDownloader.rejectHandler)
      );
  }

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

QingJ © 2025

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