chyoa story depaginator

depaginates chyoa stories by adding previous chapter to top - go to deepest chapter to see whole thread

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         chyoa story depaginator
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  depaginates chyoa stories by adding previous chapter to top - go to deepest chapter to see whole thread
// @author       You
// @match        https://chyoa.com/chapter/*
// @match        http://chyoa.com/chapter/*
// @match        https://chyoa.com/index.php/chapter/*
// @require      http://code.jquery.com/jquery-latest.js
// @grant        none
// ==/UserScript==

//turn off noscript for site
//first get requests gets same story chapter, so that is an edge case, not sure why

var more = true;
var nextLink = $(".controls-left > a:nth-child(1)").href;
var first = true;

function all() {
    $.ajax({
        type: "GET",
        url: nextLink,
        success: function(data) {
            text = $(data).find(".chapter-content");
            nextLink = $(data).find(".controls-left")[0].childNodes[1].href;
            if (first) {
                $(".chapter-content")[0].innerHTML = "";
                first = false;
            }

            if (!first) {
                $(".chapter-content").prepend("<div>"+text[0].innerHTML+"</div>");
            }

            if (nextLink.split("/")[3] == "story" || nextLink.split("/")[4] == "story") {
                more = false;
            }
            if (more) {
                all();
            }
        }
    })
}

all();

function removeCSS() {
    for (let i = 0; i < document.styleSheets.length; i++) {
        document.styleSheets[i].disabled = true;
    }
}

removeCSS();