Thieme eRef Ripper

Download all PDF from an eBook

目前為 2019-12-14 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Thieme eRef Ripper
// @namespace    http://tampermonkey.net/
// @version      1.2
// @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
// ==/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;
    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);
        downAllLi.appendChild(downAll);
this.insertBefore(downAllLi, this.firstChild);

});



function download_files(files) {
	for (var i = 0; i < files.length; i++) {

        GM_download(files[i].download, name+ "/" + files[i].filename);

    };

    alert("Downloading...");

}
    function getBaseUrl() {
            return window.location.protocol + "//" + window.location.host + "/" + window.location.pathname.split('/')[1];
    }



})();