// Wait for the page to load completely await new Promise(resolve => { if (document.readyState === 'complete') { resolve(); } else { window.addEventListener('load', resolve); } });
// Get all image elements with class m-viewer-page-comic-img const imageElements = document.querySelectorAll('.m-viewer-page-comic-img'); if (imageElements.length === 0) { console.error('No images found on the page'); return; }
// Extract image URLs from src attributes const imageURLs = Array.from(imageElements).map(img => { // Get the highest quality version if available const src = img.src || img.getAttribute('data-src') || ''; return src.replace(/@w_\d+/, '@w_2000'); // Try to get higher resolution }).filter(url => url);
// Get title from the page const titleElement = document.querySelector('.m-viewer-header-title') || document.querySelector('title'); const title = titleElement ? titleElement.textContent.trim().split(' -')[0].replace(' ', ' ') : `comic_${Date.now()}`;
适配comic-ryu.jp新网页结构及unicorn.comic-ryu.jp
// ==UserScript==
// @name ComicRyuDownloader
// @namespace https://github.com/Timesient/manga-download-scripts
// @version 0.5
// @license GPL-3.0
// @author Timesient
// @description Manga downloader for comic-ryu.jp
// @icon https://comic-ryu.jp/img/icon.png
// @homepageURL https://greasyfork.org.cn/zh-CN/scripts/455399-comicryudownloader
// @supportURL https://github.com/Timesient/manga-download-scripts/issues
// @match https://*.comic-ryu.jp/*/
// @require https://unpkg.com/axios@0.27.2/dist/axios.min.js
// @require https://unpkg.com/jszip@3.7.1/dist/jszip.min.js
// @require https://unpkg.com/file-saver@2.0.5/dist/FileSaver.min.js
// @require https://update.greasyfork.org.cn/scripts/451810/1398192/ImageDownloaderLib.js
// @grant GM_info
// ==/UserScript==
(async function(axios, JSZip, saveAs, ImageDownloader) {
'use strict';
// Wait for the page to load completely
await new Promise(resolve => {
if (document.readyState === 'complete') {
resolve();
} else {
window.addEventListener('load', resolve);
}
});
// Get all image elements with class m-viewer-page-comic-img
const imageElements = document.querySelectorAll('.m-viewer-page-comic-img');
if (imageElements.length === 0) {
console.error('No images found on the page');
return;
}
// Extract image URLs from src attributes
const imageURLs = Array.from(imageElements).map(img => {
// Get the highest quality version if available
const src = img.src || img.getAttribute('data-src') || '';
return src.replace(/@w_\d+/, '@w_2000'); // Try to get higher resolution
}).filter(url => url);
// Get title from the page
const titleElement = document.querySelector('.m-viewer-header-title') ||
document.querySelector('title');
const title = titleElement ? titleElement.textContent.trim().split(' -')[0].replace(' ', ' ') :
`comic_${Date.now()}`;
// Setup ImageDownloader
ImageDownloader.init({
maxImageAmount: imageURLs.length,
getImagePromises: getImagePromises,
title: title
});
// Collect promises of image downloads
function getImagePromises(startNum, endNum) {
return imageURLs
.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);