Sprinter

autostart video + skip intro/outro

Verze ze dne 04. 01. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Sprinter
// @namespace    http://tampermonkey.net/
// @version      2.1
// @description  autostart video + skip intro/outro
// @match        https://jut.su/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    let wasPlayClicked = false;
    window.addEventListener('load', () => {
        const pb = document.querySelector('button.vjs-big-play-button');
        if (pb && !wasPlayClicked) {
            pb.click();
            wasPlayClicked = true;
        }
    });

    const tasks = new WeakMap();
    function scheduleClick(el) {
        if (!el.classList.contains('vjs-hidden')) {
            if (!tasks.has(el)) {
                const timer = setTimeout(() => {
                    el.click();
                    tasks.delete(el);
                }, 2000);
                tasks.set(el, timer);
            }
        } else if (tasks.has(el)) {
            clearTimeout(tasks.get(el));
            tasks.delete(el);
        }
    }

    const observer = new MutationObserver(mutations => {
        for (const mutation of mutations) {
            if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
                const t = mutation.target;
                if (
                    t.matches('div.vjs-overlay-skip-intro') ||
                    (
                        t.matches('div.vjs-overlay') &&
                        (/пропустить заставку/i.test(t.textContent) || /следующая серия/i.test(t.textContent))
                    )
                ) {
                    scheduleClick(t);
                }
            }
        }
    });

    observer.observe(document.body, { attributes: true, subtree: true });

    function init() {
        const els = document.querySelectorAll('div.vjs-overlay-skip-intro, div.vjs-overlay');
        els.forEach(el => {
            if (
                el.matches('div.vjs-overlay-skip-intro') ||
                /пропустить заставку/i.test(el.textContent) ||
                /следующая серия/i.test(el.textContent)
            ) {
                scheduleClick(el);
            }
        });
    }

    window.addEventListener('load', init);
})();