HITOMI GALLERY PAGE LOADER

script for loading pages inside galleries on hitomi.la

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         HITOMI GALLERY PAGE LOADER
// @namespace    https://greasyfork.org
// @version      2024-10-06
// @description  script for loading pages inside galleries on hitomi.la
// @author       qwertybot
// @match        https://hitomi.la/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
let pageNum = 1;
let intervalId;
let isPaused = false;
let isCodeExecuted = false;


if (window.location.href.endsWith('.html#1')) {

    function createOriginalThumbnailContainer() {
        let originalThumbnailList = document.querySelector('ul.thumbnail-list');


        let originalContainer = document.createElement('div');
        originalContainer.appendChild(originalThumbnailList.cloneNode(true));


        document.querySelector('div.simplePagerContainer').appendChild(originalContainer);
    }


    function loadNextPage() {
        if (isPaused) return;


        let nextPageSelector = 'li.simplePageNav' + (pageNum + 1) + ' a';
        let nextLink = document.querySelector(nextPageSelector);


        if (nextLink) {

            nextLink.click();


            pageNum++;


            setTimeout(() => {

                let newThumbnailList = document.querySelector('ul.thumbnail-list');


                if (newThumbnailList) {

                    let galleryContainer = document.createElement('div');
                    galleryContainer.appendChild(newThumbnailList.cloneNode(true));


                    document.querySelector('div.simplePagerContainer').appendChild(galleryContainer);
                }
            }, 1000);
        } else {
            console.log('No next page. Hide original thumbnail-list and stop.');
            document.querySelector('ul.thumbnail-list').style.display = 'none';
            clearInterval(intervalId);
        }
    }


    function togglePause() {
        isPaused = !isPaused;
        const pauseButton = document.getElementById('pause-button');
        pauseButton.innerText = isPaused ? 'Continue' : 'Pause';
    }


    function createPauseButton() {
        const pauseButton = document.createElement('button');
        pauseButton.id = 'pause-button';
        pauseButton.innerText = 'Pause';
        pauseButton.style.position = 'fixed';
        pauseButton.style.top = '10px';
        pauseButton.style.right = '10px';
        pauseButton.style.zIndex = '9999';
        pauseButton.style.padding = '10px 15px';
        pauseButton.style.backgroundColor = '#ff5722';
        pauseButton.style.color = '#fff';
        pauseButton.style.border = 'none';
        pauseButton.style.borderRadius = '5px';
        pauseButton.style.cursor = 'pointer';
        pauseButton.addEventListener('click', togglePause);
        document.body.appendChild(pauseButton);
    }


    createOriginalThumbnailContainer();
    createPauseButton();


    isCodeExecuted = true;


    intervalId = setInterval(loadNextPage, 1500);
} else {
    console.log('Wrong page, script on pause.');
}
})();