Zelenka.guru Page Navigation

Allows navigation to a specific page on Zelenka.guru threads

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();