Greasy Fork

Skip half-chapters

Changes "Next chapter" button to the next full chapter if present

目前为 2025-01-29 提交的版本。查看 最新版本

// ==UserScript==
// @name         Skip half-chapters
// @namespace    http://tampermonkey.net/
// @version      2025-01-28
// @description  Changes "Next chapter" button to the next full chapter if present
// @author       You
// @match        https://chapmanganato.to/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=chapmanganato.to
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const buttons = document.querySelectorAll(".navi-change-chapter-btn-next");
    console.log(buttons);
    const currentChapter = parseInt(location.href.match(/.+?\/chapter-(\d+)/)[1]);
    const chapters = [...document.querySelectorAll(".navi-change-chapter option")];
    let nextChapterExists = false;
    for (const option of chapters) {
        if (option.getAttribute('data-c') === (currentChapter + 1).toString()) {
            console.log(option);
            nextChapterExists = true;
            break;
        }
    }
    if (!nextChapterExists) {
        console.warn("No next chapter, exiting");
        return;
    }

    const nextUrl = location.href.replace(/\/chapter-(.+)/, `/chapter-${currentChapter + 1}`);
    console.log('Next chapter url', nextUrl);

    for (const button of buttons) {
        button.href = nextUrl;
        button.innerHTML = 'NEXT CHAPTER (FULL) <i></i>';
    }
    // Your code here...
})();