ePaveldas.lt Downloader

Генерирует ссылки для скачивания изображений с сайта epaveldas.lt

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         ePaveldas.lt Downloader
// @namespace    nikku
// @license      MIT
// @version      0.2
// @description  Генерирует ссылки для скачивания изображений с сайта epaveldas.lt
// @author       nikku
// @match        https://www.epaveldas.lt/preview?id=*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=epaveldas.lt
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/FileSaver.min.js
// @run-at       document-start
// @grant        none
// ==/UserScript==

/* global saveAs */

function processData(data) {
    let text = '';
    const items = Object.keys(data.resourcesFull);
    let file = `${data.providerCode}_${data.id}_${data.title.slice(0, 160)} [${items.length}].txt`;
    file = file.replace(/[/\\?%*:|"<>]/g, '_');

    items.forEach(function(item) {
        text += item + '\r\n';
    });

    const btn = document.createElement('button');
    btn.id = 'down_links';
    btn.className = 'mat-subheading-2';
    btn.style.width = '100%';
    btn.title = 'Скачать список ссылок';
    btn.textContent = 'Download all page links';
    btn.addEventListener('click', function() {
        saveAs(new Blob([text], {type: 'text/plain;charset=utf-8'}), file);
    });

    let stopObserve = false;
    const observer = new MutationObserver(function (mutList) {
        for (let i = 0; i < mutList.length; i++) {
            for (let j = 0; j < mutList[i].addedNodes.length; j++) {
                if (mutList[i].addedNodes[j].classList.contains('preview')) {
                    mutList[i].addedNodes[j].querySelector('.kpo-details__right').prepend(btn);
                    observer.disconnect();
                    stopObserve = true;
                    break;
                }
            }
            if (stopObserve) {
                break;
            }
        }
    });

    observer.observe(document.body, {
        subtree: true, childList: true
    });
}

(function(open) {
    XMLHttpRequest.prototype.open = function() {
        if (arguments[1].includes('findById')) {
            this.addEventListener('load', function() {
                const json = JSON.parse(this.responseText);
                processData(json);
            }, false);
        }

        open.apply(this, arguments);
    };
})(XMLHttpRequest.prototype.open);