위티비 인트로 100초 건너뛰기 Tampermonkey 스크립트 (수정)

https://sngall.com/articles/101497
2025/05/12 20:17
조회수: 125

PC 브라우저 확장 프로그램에 Tampermonkey 설치하고 새 스크립트 추가 해서 아래 붙여넣기 하면 됨 

 

// ==UserScript==
// @name         WeTV Smart Intro Skipper (90s threshold, SPA support)
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  Skips to 100s if video starts before 90s. Works even with WeTV's episode switching (SPA aware). No skip if resuming from later time.
// @author       ChatGPT
// @match        https://wetv.vip/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    function applySkipLogic() {
        let hasSeeked = false;
        let maxWaitTime = 10000;
        let startTime = Date.now();

        const checkInterval = setInterval(() => {
            const video = document.querySelector('video');
            if (video && !hasSeeked) {
                if (video.readyState >= 1) {
                    const trySeek = () => {
                        if (!hasSeeked && video.duration > 100 && video.currentTime < 90) {
                            video.currentTime = 100;
                            hasSeeked = true;
                            console.log('⏩ Skipped to 100s');
                        }
                    };

                    video.addEventListener('play', trySeek, { once: true });

                    if (!video.paused) {
                        trySeek();
                    }

                    clearInterval(checkInterval);
                }
            }

            if (Date.now() - startTime > maxWaitTime) {
                clearInterval(checkInterval);
            }
        }, 500);
    }

    function hookIntoSPARouting() {
        const originalPushState = history.pushState;
        const originalReplaceState = history.replaceState;

        function onUrlChange() {
            console.log('🔁 Detected URL change to:', location.href);
            setTimeout(applySkipLogic, 1000); // Give some time for new video to load
        }

        history.pushState = function (...args) {
            originalPushState.apply(this, args);
            onUrlChange();
        };

        history.replaceState = function (...args) {
            originalReplaceState.apply(this, args);
            onUrlChange();
        };

        window.addEventListener('popstate', onUrlChange);
    }

    // Run on initial load
    applySkipLogic();
    hookIntoSPARouting();
})();

 

저절로 점프되는 기능이 자꾸 안 되길래 챗지피티로 만들었음ㅋㅋ 

내가 확인하기로는 위티비 드라마는 대부분 인트로가 100초던데 혹시 100초가 아닌 영상이 있으면 안 맞을 거임ㅋㅋ 그리고 가끔 그냥 로딩 타이밍이 안 맞아서 안 될지도 모름

근데 나는 지금 잘 쓰고 있다ㅋㅋ


code: [123ce]
목록 Gift

댓글


목록