function retrieveNovelChapterTableMaxPage (HTML, selector, retries){
    const $ = cheerio.load(HTML);

    pretty.logPrint("Retrieving chapter table max page...");

    try{
        
        // Last index is always the -> button, if it does not exist, default to 0
        let page_length = ($(selector).get().length) - 2;
        page_length = page_length < 0 ? 0 : page_length

        // Last page is usually the last anchor tag before the ->
        let last_page = $($(selector).get(page_length)).text();

        pretty.logPrint("Sucessfully retrieved chapter table max page.");
        return parseInt(last_page);
    }catch(err){

        if(retries>0){
            
            errDict.getError(12);
            errDict.customError(err.message);
            pretty.logPrint(`Retrying to max page of chapter table... (Retries left: ${retries-1})`);
            return retrieveNovelChapterTableMaxPage(HTML,selector,retries-1);
        }
        else{
            errDict.getError(13);
            return null;
        }
    }

}
/**
 * Retrieves the max page number of the chapter table of the novel.
 * 
 * @param {String} HTML The Novel Page HTML body retrieved from the request package
 * @param {String} selector The set of string CSS selector for the pagination
 * @param {Number} retries This is the maximum number of retries till error gets thrown
 * 
 * @returns The max page of the chapter table, null if error or does not exist.
 */
Retrieves the max page number of the chapter table of the novel.

@param {String} HTML The Novel Page HTML body retrieved from the request package
@param {String} selector The set of string CSS selector for the pagination
@param {Number} retries This is the maximum number of retries till error gets thrown

@returns The max page of the chapter table, null if error or does not exist.
Retrieves the max page number of the chapter table of the novel . @param { String } HTML The Novel Page HTML body retrieved from the request package @param { String } selector The set of string CSS selector for the pagination @param { Number } retries This is the maximum number of retries till error gets thrown @returns The max page of the chapter table null if error or does not exist .
function retrieveNovelChapterTableMaxPage (HTML, selector, retries){
    const $ = cheerio.load(HTML);
    pretty.logPrint("Retrieving chapter table max page...");
    try{
        let page_length = ($(selector).get().length) - 2;
        page_length = page_length < 0 ? 0 : page_length
        let last_page = $($(selector).get(page_length)).text();
        pretty.logPrint("Sucessfully retrieved chapter table max page.");
        return parseInt(last_page);
    }catch(err){
        if(retries>0){
            errDict.getError(12);
            errDict.customError(err.message);
            pretty.logPrint(`Retrying to max page of chapter table... (Retries left: ${retries-1})`);
            return retrieveNovelChapterTableMaxPage(HTML,selector,retries-1);
        }
        else{
            errDict.getError(13);
            return null;
        }
    }
}
function retrieveNovelChapterTableMaxPage ( HTML , selector , retries ) { const $ = cheerio . load ( HTML ) ; pretty . logPrint ( "Retrieving chapter table max page..." ) ; try { let page_length = ( $ ( selector ) . get ( ) . length ) - 2 ; page_length = page_length < 0 ? 0 : page_length let last_page = $ ( $ ( selector ) . get ( page_length ) ) . text ( ) ; pretty . logPrint ( "Sucessfully retrieved chapter table max page." ) ; return parseInt ( last_page ) ; } catch ( err ) { if ( retries > 0 ) { errDict . getError ( 12 ) ; errDict . customError ( err . message ) ; pretty . logPrint ( ` ${ retries - 1 } ` ) ; return retrieveNovelChapterTableMaxPage ( HTML , selector , retries - 1 ) ; } else { errDict . getError ( 13 ) ; return null ; } } }
Retrieves the max page number of the chapter table of the novel.
Retrieves the max page number of the chapter table of the novel .
// Last index is always the -> button, if it does not exist, default to 0 // Last page is usually the last anchor tag before the ->