ePaveldas.lt Downloader

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);