Добавить shikimori_one_dwimg_Nyako/script.user.js
This commit is contained in:
@@ -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;
|
||||||
Reference in New Issue
Block a user