Coub.com Auto Scroll

Auto-scroll in Coub.com all 20 Seconds.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Coub.com Auto Scroll
// @namespace    coub-auto-scroll-h1ghsyst3m
// @version      0.6
// @license      MIT
// @description  Auto-scroll in Coub.com all 20 Seconds.
// @author       H1ghSyst3m
// @match        https://coub.com
// @match        https://coub.com/*
// @exclude      https://coub.com/view/*
// @exclude      https://coub.com/embed/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var scrollInterval;
    var intervalTime = 20000; // 20 seconds
    var isAutoScrollPaused = false;

    function setScrollInterval() {
        clearScrollInterval();
        if (!isAutoScrollPaused) {
            scrollInterval = setInterval(scrollNextCoub, intervalTime);
        }
    }

    function clearScrollInterval() {
        clearInterval(scrollInterval);
    }

    function scrollNextCoub() {
        var nextCoub = document.querySelector("div.coub.active").nextSibling;
        nextCoub.scrollIntoView({ behavior: 'smooth', block: 'end' });
        setScrollInterval();
    }

    function scrollPrevCoub() {
        var prevCoub = document.querySelector("div.coub.active").previousSibling;
        prevCoub.scrollIntoView({ behavior: 'smooth', block: 'end' });
        setScrollInterval();
    }

    function toggleAutoScroll() {
        isAutoScrollPaused = !isAutoScrollPaused;
        isAutoScrollPaused ? clearScrollInterval() : setScrollInterval();
        pauseButton.innerHTML = isAutoScrollPaused ? '▶' : '⏸';
    }

    // Add scroll controls
    var scrollDown = createButton('↓', scrollNextCoub);
    var scrollUp = createButton('↑', scrollPrevCoub);
    var pauseButton = createButton('⏸', toggleAutoScroll);

    // Utility function to create a button
    function createButton(symbol, onClickFunction) {
        var button = document.createElement("div");
        button.style = "position:fixed;z-index:9900;right:20px;bottom:100px;opacity:70%;background-color:#2196F3;color:white;border:2px solid white;font-weight:bold;display:flex;align-items:center;justify-content:center;width:50px;height:50px;border-radius:25px;font-size:20pt;cursor:pointer;margin-bottom:10px;";
        button.innerHTML = symbol;
        button.onclick = onClickFunction;
        document.body.appendChild(button);
        return button;
    }

    // Positioning the buttons
    scrollDown.style.bottom = '100px';
    scrollUp.style.bottom = '160px';
    pauseButton.style.bottom = '220px';

    // Initialize the auto-scroll interval
    setScrollInterval();
})();