From e8977f35ad7f1b79cdc832d74e373cab933b7bf3 Mon Sep 17 00:00:00 2001 From: Nyako Date: Mon, 1 Jun 2026 11:59:58 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20shikimori=5Fone=5Fdwimg=5FNyako/script.user.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shikimori_one_dwimg_Nyako/script.user.js | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 shikimori_one_dwimg_Nyako/script.user.js diff --git a/shikimori_one_dwimg_Nyako/script.user.js b/shikimori_one_dwimg_Nyako/script.user.js new file mode 100644 index 0000000..4da9590 --- /dev/null +++ b/shikimori_one_dwimg_Nyako/script.user.js @@ -0,0 +1,73 @@ +// ==UserScript== +// @name Загрузчик изображений с shikimori.one +// @name:en Shikimori.one images downloader +// @namespace shikimori_one_dwimg_Nyako +// @match https://shikimori.one/clubs/*/images +// @match https://shikimori.io/clubs/*/images +// @grant none +// @version 0.1.1b +// @author https://t.me/Nyako_TW +// @license Apache License 2.0 +// @downloadURL https://git.nekono.su/Nyako/script-dev-ru/raw/branch/main/shikimori_one_dwimg_Nyako/script.user.js +// @updateURL https://git.nekono.su/Nyako/script-dev-ru/raw/branch/main/shikimori_one_dwimg_Nyako/script.user.js +// @description 08.04.2025, 12:36:52 +// @description:en 08.04.2025, 12:36:52 +// ==/UserScript== + +/* jshint esversion: 8 */ + +button = document.createElement("button"); +button.innerHTML = "Скачать всё"; +button.setAttribute("onclick", "dw_all_club_images()"); +document.getElementsByClassName("b-breadcrumbs")[0].appendChild(button); + +src1 = document.createElement("script"); +src1.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"); +src2 = document.createElement("script"); +src2.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"); +document.getElementsByTagName("head")[0].appendChild(src1); +document.getElementsByTagName("head")[0].appendChild(src2); + +const fileUrls = [ + 'https://example.com/file1.txt', + 'https://example.com/file2.jpg', + 'https://example.com/file3.pdf' +]; + +async function fetchFile(url) { + const response = await fetch(url); + if (!response.ok) { + throw new Error(`Failed to fetch ${url}: ${response.statusText}`); + } + return await response.blob(); +} + +async function downloadFilesAsZip(urls, name_file) { + const zip = new JSZip(); + try { + const filePromises = urls.map(async (url, index) => { + const blob = await fetchFile(url); + const fileName = url.split('/').pop().split("?")[0]; + zip.file(fileName, blob); + }); + await Promise.all(filePromises); + const content = await zip.generateAsync({ type: 'blob' }); + saveAs(content, name_file); + console.log('ZIP-архив успешно создан и сохранен.'); + } catch (error) { + console.error('Ошибка при создании ZIP-архива:', error); + } +} + +function dw_all_club_images () { + all_images = document.getElementsByClassName("b-image"); + urls_dw = []; + for (const one_image of all_images) { + url_dw = one_image.href; + urls_dw.push(url_dw); + } + name_file = window.location.pathname.split("/")[2] + ".zip"; + downloadFilesAsZip(urls_dw, name_file); +} + +unsafeWindow.dw_all_club_images = dw_all_club_images; \ No newline at end of file