Blinkist "Today's Free Blink" text scraper ("new-reader")

This script combines the chapter texts into one text.

Verze ze dne 10. 06. 2022. Zobrazit nejnovější verzi.

// ==UserScript==
// @name         Blinkist "Today's Free Blink" text scraper ("new-reader")
// @description  This script combines the chapter texts into one text.
// @namespace    http://tampermonkey.net/
// @version      0.5
// @author       scr1ptst3r
// @match        https://www.blinkist.com/de/nc/new-reader/*
// @match        https://www.blinkist.com/en/nc/new-reader/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=blinkist.com
// @grant        none
// @license      MIT
// ==/UserScript==
/* jshint esversion: 6 */
(function () {
    'use strict';

    let fullText = ""
    let part = 0

    function f1() {
        if (document.querySelector(".reader-content")) {
            const segment = document.querySelector(".reader-content").innerText.replace("Mark as finished", "")
            fullText += segment + "\n\n"
            console.log(`scraper script: text segment ${++part} added`)
        }

        if (document.querySelector(".reader-content__next")) {
            if (document.querySelector(".reader-content__next").style.display === "none") {
                console.log(`scraper script: text complete:`)
                console.log(fullText)
                const blinkistWindow = window.open("", "Blinkist Text", "top=10,left=10,width=900,height=1000")
                fullText = fullText.replace(/\n/g, "<br>")
                blinkistWindow.document.write(fullText)
            } else {
                document.querySelector(".reader-content__next").click()
                setTimeout(() => { f1() }, 2000)
            }
        }
    }

    //f1()
    window.addEventListener('load', () => {
        console.log(`scraper script: starting in 2 seconds`)
        setTimeout(() => { f1() }, 2000)
    })

})();