Sprinter

autostart video + skip intro/outro

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Sprinter
// @author       _Aldan_
// @namespace    http://tampermonkey.net/
// @version      2.2
// @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);
})();