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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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;
    }

}