Greasy Fork

ZeroSumOnline Downloader

Descarga imágenes de capítulos desde ZeroSumOnline.

目前为 2024-11-26 提交的版本。查看 最新版本

// ==UserScript==
// @name         ZeroSumOnline Downloader
// @namespace    custom-scripts
// @version      1.0
// @description  Descarga imágenes de capítulos desde ZeroSumOnline.
// @author       TuNombre
// @license      MIT
// @match        https://zerosumonline.com/*
// @grant        GM_download
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function () {
    "use strict";

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

    downloadButton.addEventListener("click", async () => {
        const images = Array.from(document.querySelectorAll("img.G54Y0W_page"));
        if (images.length === 0) {
            alert("No se encontraron imágenes para descargar.");
            return;
        }

        for (let i = 0; i < images.length; i++) {
            const imgElement = images[i];
            const blobUrl = imgElement.src;

            try {
                const blob = await fetch(blobUrl).then(res => res.blob());
                const fileName = `page_${String(i + 1).padStart(3, "0")}.jpg`;
                downloadBlob(blob, fileName);
                console.log(`Imagen descargada: ${fileName}`);
            } catch (error) {
                console.error(`Error descargando la imagen ${i + 1}:`, error);
            }
        }

        alert(`${images.length} imágenes descargadas correctamente.`);
    });

    function downloadBlob(blob, fileName) {
        const a = document.createElement("a");
        const url = URL.createObjectURL(blob);
        a.href = url;
        a.download = fileName;
        document.body.appendChild(a);
        a.click();
        a.remove();
        URL.revokeObjectURL(url);
    }
})();