Greasy Fork

Greasy Fork is available in English.

Webtoon Scroller [Shift-Q]

Auto scroll on webtoon with configurable speed (press Shift+Q for menu, Q to toggle scrolling)

当前为 2025-01-04 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Webtoon Scroller [Shift-Q]
// @namespace    http://tampermonkey.net/
// @version      1.1.1
// @description  Auto scroll on webtoon with configurable speed (press Shift+Q for menu, Q to toggle scrolling)
// @author       GavinGoGaming
// @license      GPL-2.0
// @match        https://www.webtoons.com/en/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=webtoons.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    let toggled = false;
    let scrollSpeed = 30;
    let interval;

    const createConfigMenu = () => {
        const menu = document.createElement('div');
        menu.id = 'scroll-config-menu';
        menu.style.position = 'fixed';
        menu.style.top = '50%';
        menu.style.left = '50%';
        menu.style.transform = 'translate(-50%, -50%)';
        menu.style.background = '#fff';
        menu.style.border = '1px solid #ccc';
        menu.style.borderRadius = '8px';
        menu.style.boxShadow = '0px 4px 8px rgba(0, 0, 0, 0.2)';
        menu.style.padding = '16px';
        menu.style.display = 'none';
        menu.style.zIndex = '10000';

        menu.innerHTML = `
            <label for="scroll-speed">Scroll Speed (ms):</label>
            <input type="number" id="scroll-speed" value="${scrollSpeed}" style="width: 80px; margin-left: 8px;">
            <button id="save-scroll-config" style="margin-left: 8px;">Save</button>
            <button id="close-scroll-config" style="margin-left: 8px;">Close</button>
            <button id="toggle-scroll-config" style="margin-left: 8px;">Toggle</button>
        `;

        document.body.appendChild(menu);

        document.getElementById('save-scroll-config').onclick = () => {
            const speedInput = document.getElementById('scroll-speed');
            const newSpeed = parseInt(speedInput.value, 10);
            if (!isNaN(newSpeed) && newSpeed > 0) {
                scrollSpeed = newSpeed;
                alert(`Scroll speed set to ${scrollSpeed} ms.`);
            } else {
                alert('Invalid scroll speed value. Please enter a positive number.');
            }
        };

        document.getElementById('close-scroll-config').onclick = () => {
            menu.style.display = 'none';
        };
        document.getElementById('toggle-scroll-config').onclick = () => {
            toggleScrolling();
        };
    };

    const toggleScrolling = () => {
        if (toggled) {
            clearInterval(interval);
            toggled = false;
        } else {
            interval = setInterval(() => {
                document.documentElement.scrollBy(0, 1);
            }, scrollSpeed);
            toggled = true;
        }
    };

    const toggleConfigMenu = () => {
        const menu = document.getElementById('scroll-config-menu');
        if (menu.style.display === 'none') {
            menu.style.display = 'block';
        } else {
            menu.style.display = 'none';
        }
    };

    document.addEventListener('keydown', (event) => {
        if (event.key === 'q') {
            if(event.shiftKey) return toggleConfigMenu();
            toggleScrolling();
        }
    });

    createConfigMenu();
})();