Jutsu +

Наведитесь на кнопку серии чтобы посмотреть названия и кадр, Автоматический пропуст интро и переключение на следующий эпизод

// ==UserScript==
// @name         Jutsu +
// @namespace    by
// @version      1.1
// @author       diorhc
// @description  Наведитесь на кнопку серии чтобы посмотреть названия и кадр, Автоматический пропуст интро и переключение на следующий эпизод
// @description:en  Hover over the series button to see the titles and frame - auto skip, intro and switch to the next episode on Jut.su
// @match        https://jut.su/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=jut.su
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    // Add preview box styling
    const appendStyle = () => {
        const style = document.createElement("style");
        style.innerHTML = `
        .prevbox {
            margin-top: 55px;
            margin-left: -163px;
            display: none;
            width: 200px;
            height: auto;
            position: absolute;
            z-index: 9999;
            opacity: 0;
            transition: opacity 0.2s ease;
            box-shadow: 0 0 15px black;
            border-radius: 5px;
            border: 2px solid rgba(102, 107, 102, 0.8);
            text-align: center;
        }
        .prevbox > div {
            border-radius: 0 0 5px 5px;
            top: 10px;
            padding: 3px 14px;
            background-color: #363a37;
            min-height: max-content;
            border-top: 1px solid #505550;
        }
        .prevbox > img {
            border-radius: 5px;
            width: 200px;
            height: 112.5px;
            background: url(https://i.imgur.com/DLLjUig.png) center no-repeat rgb(54, 58, 55);
        }`;
        document.head.append(style);
    };

    // Setup preview tooltips for episode links
    const linkElements = document.querySelectorAll(`#dle-content > div > div:nth-child(2) > a[href*='${window.location.pathname}']`);
    linkElements.forEach((linkElement, index) => {
        let timeoutId = null;
        let timeoutId2 = null;
        let prevbox = document.createElement('div');
        const imgElement = document.createElement('img');
        const nameBox = document.createElement('div');
        const nameElement = document.createElement('text');
        nameBox.append(nameElement);

        prevbox.id = `prevbox-${index}`;
        prevbox.className = "prevbox";
        imgElement.style.width = '200px';
        imgElement.style.height = '112.5px';

        let loaded = false;

        if (localStorage[linkElement.href] && localStorage[linkElement.href + "name"]) {
            loaded = true;
            imgElement.src = localStorage[linkElement.href];
            nameElement.innerText = localStorage[linkElement.href + "name"];

            prevbox.prepend(nameBox);
            prevbox.prepend(imgElement);
            linkElement.insertAdjacentElement('afterend', prevbox);
        }
        linkElement.addEventListener('mouseenter', () => {
            clearTimeout(timeoutId);
            clearTimeout(timeoutId2);

            timeoutId = setTimeout(() => {
                if (!loaded) {
                    loaded = true;
                    fetch(linkElement.href)
                        .then(response => response.arrayBuffer())
                        .then(buffer => {
                            prevbox.prepend(nameBox);
                            prevbox.prepend(imgElement);
                            linkElement.insertAdjacentElement('afterend', prevbox);
                            let html = new TextDecoder('windows-1251').decode(buffer);
                            const doc = document.createElement("test");
                            doc.innerHTML = html;
                            const imgUrl = doc.querySelector(`meta[property="og:image"]`).content;
                            console.log(doc.querySelector("#dle-content div.video_plate_title h2"));
                            const nameText = doc.querySelector("#dle-content div.video_plate_title h2").innerHTML;
                            nameElement.innerText = nameText;
                            localStorage[linkElement.href + "name"] = nameText;
                            imgElement.src = imgUrl;

                            localStorage[linkElement.href] = imgUrl;
                        })
                        .catch(error => {
                            loaded = false;
                            console.error(error);
                        });
                }
                prevbox.style.opacity = '0';
                prevbox.style.display = "unset";
            }, 200);
            timeoutId2 = setTimeout(() => {
                prevbox.style.opacity = '1';
            }, 500)

        });

        linkElement.addEventListener('mouseleave', () => {
            clearTimeout(timeoutId);
            clearTimeout(timeoutId2);
            prevbox.style.opacity = '0';
            setTimeout(() => {
                prevbox.style.display = "none";
            }, 200)
        });
    });

    // Handle auto-skip for intros and auto-play functionality
    const setupAutoSkip = () => {
        const isVisible = elem => elem && elem.offsetParent !== null;

        const checkForButtons = () => {
            const opening = document.querySelector("div[title='Нажмите, если лень смотреть опенинг']");
            const ending = document.querySelector("div[title='Перейти к следующему эпизоду']");
            const playButton = document.querySelector("button[title='Воспроизвести видео']");

            if (isVisible(opening)) opening.click();
            if (isVisible(ending)) ending.click();
            if (isVisible(playButton)) playButton.click();

            // Use shorter timeout for regular checks, longer after clicking buttons
            const delay = isVisible(opening) || isVisible(ending) ? 5000 : 250;
            setTimeout(checkForButtons, delay);
        };

        checkForButtons();
    };

    // Initialize everything
    setTimeout(() => {
        appendStyle();
    }, 1000);

    setupAutoSkip();
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元