// ==UserScript== // @name ZeroSumOnline Manga Downloader // @namespace custom-scripts // @version 1.1 // @description Descarga imágenes de capítulos de manga desde ZeroSumOnline con manejo de URLs tipo blob. // @author TuNombre // @license MIT // @match https://zerosumonline.com/* // @grant GM_download // @downloadURL none // ==/UserScript== (function () { "use strict"; // Crear botón para iniciar la 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); // Evento del botón 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++) { try { const imgElement = images[i]; const blob = await getImageBlob(imgElement); 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.`); }); // Convierte la URL blob en un Blob descargable function getImageBlob(imgElement) { return new Promise((resolve, reject) => { try { const canvas = document.createElement("canvas"); canvas.width = imgElement.naturalWidth; canvas.height = imgElement.naturalHeight; const ctx = canvas.getContext("2d"); ctx.drawImage(imgElement, 0, 0); canvas.toBlob(resolve, "image/jpeg"); } catch (error) { reject(error); } }); } // Descarga un Blob con nombre de archivo 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); } })();