Auto Scroll YouTube Shorts

Automatically scrolls to the next YouTube short when the current one finishes.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Auto Scroll YouTube Shorts
// @namespace    https://github.com/Navist/YouTubeShortsAutoScroll
// @version      1.0a
// @description  Automatically scrolls to the next YouTube short when the current one finishes.
// @author       Navist (AI Generated)
// @match        https://www.youtube.com/shorts/*
// @grant        none
// @license      MIT
// @homepageURL  https://github.com/Navist/YouTubeShortsAutoScroll
// @supportURL   https://github.com/Navist/YouTubeShortsAutoScroll/issues
// ==/UserScript==

(function() {
    'use strict';

    function moveToNextShort() {
        // Target the "Next" button by its class and aria-label
        const nextButton = document.querySelector(
            'button.yt-spec-button-shape-next[aria-label="Next video"]'
        );

        if (nextButton) {
            nextButton.click(); // Simulate a click on the "Next" button
            console.log("Moved to next video.");
        } else {
            console.log("Next button not found!");
        }
    }

    function checkVideoProgress() {
        const video = document.querySelector('video');
        if (video) {
            // Check if the video is about to finish (within 0.5 seconds of the duration)
            if (video.duration - video.currentTime <= 0.5) {
                moveToNextShort();
            }
        }
    }

    // Run the check every 500ms
    setInterval(checkVideoProgress, 500);
})();