Greasy Fork

Greasy Fork is available in English.

Descargar imágenes de Comic Earthstar

Detecta y descarga todas las imágenes cargadas como blobs en Comic Earthstar

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Descargar imágenes de Comic Earthstar
// @namespace    https://comic-earthstar.com/
// @version      1.0
// @description  Detecta y descarga todas las imágenes cargadas como blobs en Comic Earthstar
// @author       TuNombre
// @match        https://comic-earthstar.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    // Crear un contenedor para almacenar las URLs detectadas
    const detectedURLs = new Set();

    // Crear un botón para iniciar la descarga
    const downloadButton = document.createElement('button');
    downloadButton.innerText = 'Descargar imágenes';
    downloadButton.style.position = 'fixed';
    downloadButton.style.top = '10px';
    downloadButton.style.right = '10px';
    downloadButton.style.zIndex = '9999';
    downloadButton.style.padding = '10px';
    downloadButton.style.backgroundColor = '#28a745';
    downloadButton.style.color = 'white';
    downloadButton.style.border = 'none';
    downloadButton.style.borderRadius = '5px';
    downloadButton.style.cursor = 'pointer';
    document.body.appendChild(downloadButton);

    // Interceptar peticiones de tipo blob en la red
    const originalFetch = window.fetch;
    window.fetch = async function (...args) {
        const response = await originalFetch(...args);
        if (response.url.startsWith('blob:https://comic-earthstar.com')) {
            detectedURLs.add(response.url);
        }
        return response;
    };

    // Función para descargar las imágenes
    async function downloadImages() {
        if (detectedURLs.size === 0) {
            alert('No se detectaron imágenes para descargar.');
            return;
        }

        let counter = 1;
        for (const blobUrl of detectedURLs) {
            try {
                const blob = await fetch(blobUrl).then((res) => res.blob());
                const link = document.createElement('a');
                const url = URL.createObjectURL(blob);

                link.href = url;
                link.download = `imagen_${String(counter).padStart(3, '0')}.png`;
                link.click();

                // Liberar el objeto URL temporal
                URL.revokeObjectURL(url);
                counter++;
            } catch (error) {
                console.error('Error descargando la imagen:', blobUrl, error);
            }
        }

        alert('Descarga completa.');
    }

    // Asignar la función de descarga al botón
    downloadButton.addEventListener('click', downloadImages);
})();