SH Add Chapter Numbers

Add chapter numbers (release order) to all TOC items on a Scribble Hub series page.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         SH Add Chapter Numbers
// @namespace    ultrabenosaurus.ScribbleHub
// @version      0.2
// @description  Add chapter numbers (release order) to all TOC items on a Scribble Hub series page.
// @author       Ultrabenosaurus
// @license      GNU AGPLv3
// @source       https://greatest.deepsurf.us/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';

    UBPaginationClick();
    // run again after a delay for compatibility with my SH Auto Show Bookmark script
    setTimeout(UBPaginationClick, 1500);

})();

function UBPaginationClick(){
    if( 0 != document.querySelectorAll('div.wi_fic_table.toc:not(.ub-numbered)').length) {
        document.querySelectorAll('div.wi_fic_table.toc:not(.ub-numbered) li.toc_w[order]').forEach(function(element) {
            var linkText = element.querySelectorAll('a')[0].textContent;
            element.querySelectorAll('a')[0].textContent = "(" + element.attributes.order.value + ") " + linkText;
            linkText = null;
        });
        document.querySelectorAll('div.wi_fic_table.toc')[0].classList.add("ub-numbered");

        if( 0 != document.querySelectorAll('ul#pagination-mesh-toc li').length ){
            document.querySelectorAll('ul#pagination-mesh-toc li a').forEach(function(pagBtn) {
                if(pagBtn){
                    pagBtn.addEventListener("click", function(){
                        console.log("click");
                        setTimeout(UBPaginationClick, 800);
                    }, false);
                }
                pagBtn = null;
            });
        }
    }
}