SH List All Chapters

Override the "Show All Chapters" button to list all chapters in the Table of Contents on ScribbleHub series pages instead of a pop-up.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         SH List All Chapters
// @namespace    ultrabenosaurus.ScribbleHub
// @version      0.3
// @description  Override the "Show All Chapters" button to list all chapters in the Table of Contents on ScribbleHub series pages instead of a pop-up.
// @author       Ultrabenosaurus
// @license      GNU AGPLv3
// @source       https://greasyfork.org/en/users/437117-ultrabenosaurus?sort=name
// @match        https://www.scribblehub.com/series/*
// @icon         https://www.google.com/s2/favicons?domain=scribblehub.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    if( 0 != document.querySelectorAll('ul#pagination-mesh-toc li:nth-last-child(2)').length ){
        var top = parseInt( document.querySelectorAll('ul#pagination-mesh-toc li:nth-last-child(2)')[0].textContent );
        if( !isNaN( top ) && 1 < top ){
            //console.log(top);
            var btnElem = '<i class="fa fa-th-list chpnew" id="menu_icon_fic" aria-hidden="true" title="Show All Chapters"></i>';
            $('div.fic_toc_bar i#menu_icon_fic.fa-th-list').replaceWith(btnElem);
            var sacBtn = document.querySelectorAll('div.fic_toc_bar i#menu_icon_fic.fa-th-list')[0];
            if(sacBtn){
                sacBtn.addEventListener("click", function(){
                    UBlistAllChaptersSH( top, 2 );
                }, false);
            }
            sacBtn = btnElem = null;

            //UBlistAllChaptersSH( top, 2 );
            //top = null;
        }
    }
})();

function UBlistAllChaptersSH(top, i){
    //console.log( top, i );

    if( null != top && !isNaN( top ) && null != i && top >= i ){
        var e = $("#mypostid").attr("value");
        $.ajax({
            type: "POST",
            url: "https://www.scribblehub.com/wp-admin/admin-ajax.php",
            data: {
                action: "wi_getreleases_pagination",
                pagenum: i,
                mypostid: e
            },
            success: function(t) {
                //console.log(top, i);
                t = t.slice(0, -1);
                var ol = $(t).find('.toc_ol li');
                $('.toc_ol').append(ol);
                //console.log( ol );
                t = o = null;
                UBlistAllChaptersSH( top, i+1 );
            }
        });
    }

    if( top <= i ){
        top = null;
    }

}