Sprinter

autostart video + skip intro/outro

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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);
})();