Greasy Fork

来自缓存

Greasy Fork is available in English.

Thieme eRef Ripper

Download all PDF from an eBook

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Thieme eRef Ripper
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Download all PDF from an eBook
// @author       You
// @include      https://eref.thieme.de/ebooks/*
// @include      */ebooks/*
// @grant        GM_download
// @require      https://cdnjs.cloudflare.com/ajax/libs/arrive/2.4.1/arrive.js
// @require      https://unpkg.com/[email protected]/dist/AIO/notiflix-aio-2.1.3.min.js
// ==/UserScript==

(function() {
    'use strict';

var pdfs = [];
let name = document.getElementsByClassName("ct-ebook")[0].parentNode.textContent;
var indx = 0;

    document.arrive(".toc-tree", function() {
    // 'this' refers to the newly created element
        let downAllLi = document.createElement("li");
let downAll = document.createElement("input");
downAll.type = 'button';
downAll.value = "Download All";
downAll.addEventListener('click', function() {
    var elements = document.getElementsByClassName("tocPdfContainer");
    indx = 0;
    pdfs = [];
    for (var ie = 0; ie < elements.length; ie++) {

        if (elements[ie].getAttribute("data-pdf-link").indexOf(".pdf") !== -1) {
					indx++;

          pdfs.push({ download: getBaseUrl() + elements[ie].getAttribute("data-pdf-link"), filename: indx + "_" + name + ".pdf"});

        };



    };

 download_files(pdfs);
 
}, false);

        //append to document
downAllLi.appendChild(downAll);
this.insertBefore(downAllLi, this.firstChild);

});



function download_files(files) {

    var i = 0;

    let interval = setInterval(function () {
        if (i<files.length) {
            GM_download(files[i].download, name+ "/" + files[i].filename);
            i++;
        } else {
            clearInterval(interval);
            Notiflix.Loading.Remove();
           // You also can get your parameters as a Variable declared before. (The values have to be in String format)
            Notiflix.Report.Success( 'Success', "All downloaded to /Downloads/"+name+" folder.", 'OK' );
        }
    }, 500);

    Notiflix.Loading.Hourglass("Downloading "+files.length+" files");
}

    function getBaseUrl() {
            let url = String(window.location);
            return url.substring(0,url.indexOf("/ebooks"));
    }



})();