Zelenka.guru Page Navigation

Allows navigation to a specific page on Zelenka.guru threads

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Zelenka.guru Page Navigation
// @namespace    your_namespace_here
// @version      1.0
// @description  Allows navigation to a specific page on Zelenka.guru threads
// @author       Your Name
// @match        https://zelenka.guru/threads/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function goToPage(threadId, pageNumber) {
        const targetUrl = `https://zelenka.guru/threads/${threadId}/page-${pageNumber}`;
        window.location.href = targetUrl;
    }

    const threadId = window.location.pathname.split('/')[2];
    let pageNavContainer = null;

    // Function to check for the page navigation container
    function checkPageNavContainer() {
        pageNavContainer = document.querySelector('.PageNav');
        if (pageNavContainer) {
            clearInterval(intervalId); // Stop the interval once the button is found
            addPageNavigationButton();
        }
    }

    // Function to add the button to the page navigation container
    function addPageNavigationButton() {
        const button = document.createElement('button');
        button.innerHTML = '<i class="fa fa-angle-double-right"></i>';
        button.classList.add('custom-page-nav-button');
        button.onclick = function() {
            const pageNumber = prompt('Enter the page number:');
            if (pageNumber !== null) {
                const parsedPageNumber = parseInt(pageNumber, 10);
                if (!isNaN(parsedPageNumber) && parsedPageNumber > 0) {
                    goToPage(threadId, parsedPageNumber);
                } else {
                    alert('Invalid page number. Please enter a valid positive integer.');
                }
            }
        };

        button.style.padding = '6px';
        button.style.border = '1px solid #ccc';
        button.style.backgroundColor = '#f9f9f9';
        button.style.borderRadius = '4px';
        button.style.cursor = 'pointer';

        pageNavContainer.appendChild(button);
    }

    // Set up an interval to check for the page navigation container
    const intervalId = setInterval(checkPageNavContainer, 1000);
})();