iq.com Subtitle

자막만 가져오기

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         iq.com Subtitle
// @namespace    http://tampermonkey.net/
// @version      2.0
// @description  자막만 가져오기
// @author       yongyong
// @match        *://*.iq.com/play/*
// @run-at       document-start
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    'use strict';

    console.log("%c[Subtitle Hunter] 엔진 가동 중...", "color: #fffa00; font-weight: bold;");

    const win = typeof unsafeWindow !== 'undefined' ? unsafeWindow : window;

    function parseResponse(data) {
        try {
            const program = data?.data?.program;
            if (program && program.stl) {
                const basePath = data.data.dstl || "";
                console.log(program.stl)
                // 한국어 자막 필터링
                const korSub = program.stl.find(s =>
                    s._name?.includes("한국어") ||
                    s.name?.includes("한국어") ||
                    s.lid === 4
                );

                if (korSub && korSub.srt) {
                    const fullUrl = korSub.srt.startsWith('http') ? korSub.srt : basePath + korSub.srt;
                    console.log("%c[데이터 포착] 자막 URL:", "color: #00ecff;", fullUrl);
                    createDownloadButton(korSub._name || "한국어", fullUrl);
                } else {
                    console.log("[알림] 자막 목록은 찾았으나 한국어를 발견하지 못했습니다.");
                }
            }
        } catch (e) {
            console.error("[오류] 데이터 파싱 실패:", e);
        }
    }

    const orgFetch = win.fetch;
    win.fetch = async (...args) => {
        const response = await orgFetch(...args);
        const url = args[0] instanceof Request ? args[0].url : args[0];

        if (url.includes('dash?') || url.includes('tmts?') || url.includes('play?')) {
            const clone = response.clone();
            clone.json().then(data => parseResponse(data)).catch(() => {});
        }
        return response;
    };

    const oldSend = win.XMLHttpRequest.prototype.send;
    win.XMLHttpRequest.prototype.send = function() {
        this.addEventListener('load', function() {
            if (this.responseURL.includes('dash?') || this.responseURL.includes('tmts?')) {
                try {
                    const res = JSON.parse(this.responseText);
                    parseResponse(res);
                } catch (e) {}
            }
        });
        return oldSend.apply(this, arguments);
    };

    win.WebAssembly = undefined;

})();