Greasy Fork is available in English.

CCTV视频解析

将CCTV视频解析成HLS地址.

// ==UserScript==
// @name:en-US           CCTV-HLS
// @name                 CCTV视频解析
// @description:en-US    parse cctv video to hls url.
// @description          将CCTV视频解析成HLS地址.
// @namespace            https://greasyfork.org/users/135090
// @version              1.1.2
// @author               [ZWB](https://greasyfork.org/zh-CN/users/863179)
// @license              CC
// @grant                none
// @run-at               document-end
// @match                https://v.cctv.com/2*/V*.shtml*
// @match                https://v.cctv.cn/2*/V*.shtml*
// @match                https://tv.cctv.cn/2*/V*.shtml*
// @match                https://tv.cctv.com/2*/V*.shtml*
// @icon                 https://tv.cctv.cn/favicon.ico
// ==/UserScript==
(function () {
    function loop() {
        if ((typeof videoid) == "undefined") {
            setTimeout(loop, 500);
        }
        var hvu = "https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid=" + guid;
        if (this.videoid == "myPlayer") {
            document.querySelector("#myPlayer").innerHTML = null;
            var cctvb = document.createElement("a");
            cctvb.style.display = "grid";
            cctvb.textContent = "#JSON#";
            cctvb.style.float = "left";
            cctvb.style.fontSize = "2vw";
            cctvb.style.color = "#48EFEF";
            cctvb.href = hvu;
            document.querySelector("#via_title").appendChild(cctvb);
            $.getJSON(hvu, function (res) {
                var cctva = document.createElement("a");
                cctva.style.display = "grid";
                //cctva.textContent = "#MP4#";
                cctva.textContent = "#HLS#";
                cctva.style.float = "right";
                cctva.style.fontSize = "2vw";
                cctva.style.color = "#28EFEF";
                document.querySelector("#via_title").appendChild(cctva);
                //cctva.href = res.video.chapters4[0].url;
                cctva.href = res.hls_url.replaceAll("main", "4000");
            });
        }
        else if (videoid == "_video") {
            setTimeout(function () {
                document.querySelector("#video").innerHTML = null;
            }, 1000);
            var cctvc = document.createElement("a");
            cctvc.style.display = "grid";
            cctvc.style.float = "left";
            cctvc.textContent = "#JSON#";
            cctvc.style.fontSize = "2vw";
            cctvc.style.color = "#48EFEF";
            document.querySelector("#video").parentElement.appendChild(cctvc);
            cctvc.href = hvu;
            $.getJSON(hvu, function (res) {
                var cctva = document.createElement("a");
                cctva.style.display = "grid";
                cctva.style.float = "right";
                cctva.textContent = "#HLS#";
                cctva.style.fontSize = "2vw";
                cctva.style.color = "#28EFEF";
                var codemain = res.hls_url;
                var code1200 = codemain.replaceAll("main", "1200");
                cctva.href = code1200;
                document.querySelector("#video").parentElement.appendChild(cctva);
                var cctvv = document.createElement("a");
                cctvv.style.display = "grid";
                cctvv.style.float = "left";
                cctvv.style.width = "100%";
                cctvv.textContent = codemain;
                cctvv.style.fontSize = "2vh";
                cctvv.style.color = "#28EFEF";
                document.querySelector("#video").parentElement.appendChild(cctvv);
                cctvv.onclick = function () {
                    window.open(codemain);
                };
            });
        }
        else if (videoid == "myFlash") {
            document.querySelector("#myFlash").parentElement.innerHTML = null;
            var cctvd = document.createElement("a");
            cctvd.style.display = "grid";
            cctvd.style.float = "left";
            cctvd.textContent = "#JSON#";
            cctvd.style.fontSize = "2vw";
            cctvd.style.color = "#48EFEF";
            cctvd.href = hvu;
            document.querySelector("#page_body").children[1].firstElementChild.append(cctvd);
            $.getJSON(hvu, function (res) {
                var cctve = document.createElement("a");
                cctve.style.display = "grid";
                cctve.style.float = "right";
                cctve.textContent = "#HLS#";
                cctve.style.fontSize = "2vw";
                cctve.style.color = "#28EFEF";
                cctve.href = res.hls_url;
                document.querySelector("#page_body").children[1].firstElementChild.appendChild(cctve);
            });
        }
    }
    loop();
})();