Greasy Fork

Greasy Fork is available in English.

Comic Earthstar Advanced Manga Downloader

Descarga imágenes de mangas de Comic Earthstar, incluyendo contenido renderizado en canvas y blobs.

当前为 2024-11-27 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Comic Earthstar Advanced Manga Downloader
// @namespace    shadows
// @version      1.4.0
// @description  Descarga imágenes de mangas de Comic Earthstar, incluyendo contenido renderizado en canvas y blobs.
// @author       shadows
// @license      MIT
// @match        https://comic-earthstar.com/episode/*
// @grant        GM_download
// ==/UserScript==

"use strict";

(function () {
    // Crear botón de descarga
    const downloadButton = document.createElement("button");
    downloadButton.textContent = "Descargar Manga";
    downloadButton.style = `
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 10000;
        background-color: #28a745;
        color: white;
        border: none;
        padding: 10px 20px;
        font-size: 14px;
        border-radius: 5px;
        cursor: pointer;
    `;
    document.body.appendChild(downloadButton);

    // Evento de clic en el botón
    downloadButton.addEventListener("click", async () => {
        // Buscar imágenes renderizadas como blob
        const images = Array.from(document.querySelectorAll("img")).map(img => img.src);

        if (images.length === 0) {
            alert("No se encontraron imágenes.");
            return;
        }

        let downloadedCount = 0;

        for (const [index, imgSrc] of images.entries()) {
            try {
                // Descarga cada imagen individualmente
                await downloadBlobImage(imgSrc, `pagina_${String(index + 1).padStart(2, "0")}.png`);
                downloadedCount++;
            } catch (err) {
                console.error(`Error al descargar la imagen ${index + 1}:`, err);
            }
        }

        alert(`Se descargaron ${downloadedCount} imágenes.`);
    });

    // Función para descargar imágenes de tipo blob
    async function downloadBlobImage(blobUrl, fileName) {
        const response = await fetch(blobUrl);
        const blob = await response.blob();
        const url = URL.createObjectURL(blob);

        GM_download({
            url: url,
            name: fileName,
            onload: () => {
                URL.revokeObjectURL(url);
            },
            onerror: (err) => {
                URL.revokeObjectURL(url);
                throw err;
            },
        });
    }
})();