吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 20657|回复: 452
收起左侧

[其他原创] CCTV、央视频网站电视直播节目沉浸式观看,终版!!(完结了)

    [复制链接]
liuyang207 发表于 2026-2-22 17:56
本帖最后由 liuyang207 于 2026-3-2 11:39 编辑

终版,界面微调,黑边更少,其他小优化。如果两个网址视频ID有变化,大家可以自己修改就可以了。
打包了注入方式的EXE安装文件,玩不来油猴的网友用它,感觉这样更好用
---------------------------------------------------------------------------------------
没想到这个小东西这么多网友喜欢,还得到这么多网友支持和给分,谢了。
下面给出第五版,再次感谢大家的热心值。
修复央视不能全屏\鼠标不显示指针。现在比较完美了。
频道列表上面可以在CCTV、央视频两个网站点击跳转,懒到家了。
-----------------------------------------------------------------------------------------------------
很简单的油猴脚本,在浏览下面两个网址时,只获得你需要的内容:电视视频,频道列表。
https://tv.cctv.com/live/
https://www.yangshipin.cn/tv/
---------------------------------------------------------------------------------------------------
奉上最新的:
有打包好的浏览器EXE文件,带地址栏,可CCTV,央视频两个网址切换。给不会使用油猴的网友服用:
2026 CCTV央视直播浏览器 2.3
链接:https://pan.quark.cn/s/3c9c9403bb8f     提取码:kYyS
链接: https://pan.baidu.com/s/1qCRaChdS0yCT2Dxx0qCGGA?pwd=52pj    提取码: 52pj
---------------------------------------------------------------------------------------------------
1.png

.
2.png

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name          CCTV、央视频节目过滤脚本
// @namespace     http://tampermonkey.net/
// @version       2.3
// @description   过滤CCTV/央视频网页,只显示视频 + 右侧可滑出节目列表
// @author        作者:52PJ网Liuyang207
// @match         https://tv.cctv.com/live/*
// @match         https://www.yangshipin.cn/tv/*
// @grant         GM_addStyle
// ==/UserScript==
   
(function() {
    'use strict';
   
    const CHANNELS = [
        { n: 'CCTV-1 综合', u: '/live/cctv1/' },
        { n: 'CCTV-2 财经', u: '/live/cctv2/' },
        { n: 'CCTV-3 综艺', u: '/live/cctv3/' },
        { n: 'CCTV-4 中文国际', u: '/live/cctv4/' },
        { n: 'CCTV-5 体育', u: '/live/cctv5/' },
        { n: 'CCTV-5+ 体育赛事', u: '/live/cctv5plus/' },
        { n: 'CCTV-6 电影', u: '/live/cctv6/' },
        { n: 'CCTV-7 国防军事', u: '/live/cctv7/' },
        { n: 'CCTV-8 电视剧', u: '/live/cctv8/' },
        { n: 'CCTV-9 纪录', u: '/live/cctvjilu/' },
        { n: 'CCTV-10 科教', u: '/live/cctv10/' },
        { n: 'CCTV-11 戏曲', u: '/live/cctv11/' },
        { n: 'CCTV-12 社会与法', u: '/live/cctv12/' },
        { n: 'CCTV-13 新闻', u: '/live/cctv13/' },
        { n: 'CCTV-14 少儿', u: '/live/cctvchild/' },
        { n: 'CCTV-15 音乐', u: '/live/cctv15/' },
        { n: 'CCTV-16 奥林匹克', u: '/live/cctv16/' },
        { n: 'CCTV-17 农业农村', u: '/live/cctv17/' }
    ];
   
    const YANG_CHANNELS = [
        { n: '--- 央视频道 ---', pid: null },
        { n: 'CCTV-1 综合', pid: '600001859' },
        { n: 'CCTV-2 财经', pid: '600001800' },
        { n: 'CCTV-3 综艺', pid: '600001801' },
        { n: 'CCTV-4 中文国际', pid: '600001814' },
        { n: 'CCTV-5 体育', pid: '600001818' },
        { n: 'CCTV-5+ 体育赛事', pid: '600001817' },
        { n: 'CCTV-6 电影', pid: '600108442' },
        { n: 'CCTV-7 国防军事', pid: '600004092' },
        { n: 'CCTV-8 电视剧', pid: '600001803' },
        { n: 'CCTV-9 纪录', pid: '600004078' },
        { n: 'CCTV-10 科教', pid: '600001805' },
        { n: 'CCTV-11 戏曲', pid: '600001806' },
        { n: 'CCTV-12 社会与法', pid: '600001807' },
        { n: 'CCTV-13 新闻', pid: '600001811' },
        { n: 'CCTV-14 少儿', pid: '600001809' },
        { n: 'CCTV-15 音乐', pid: '600001815' },
        { n: 'CCTV-16 奥林匹克', pid: '600098637' },
        { n: 'CCTV-16 4K', pid: '600099502' },
        { n: 'CCTV-17 农业农村', pid: '600001810' },
        { n: 'CCTV-4K 超高清', pid: '600002264' },
        { n: 'CCTV-8K 超高清', pid: '600156816' },
        { n: 'CGTN', pid: '600014550' },
        { n: 'CGTN法语', pid: '600084704' },
        { n: 'CGTN俄语', pid: '600084758' },
        { n: 'CGTN阿拉伯语', pid: '600084782' },
        { n: 'CGTN西班牙语', pid: '600084744' },
        { n: 'CGTN外语纪录', pid: '600084781' },
        { n: 'CCTV-风云剧场', pid: '600099658' },
        { n: 'CCTV-第一剧场', pid: '600099655' },
        { n: 'CCTV-怀旧剧场', pid: '600099620' },
        { n: 'CCTV-世界地理', pid: '600099637' },
        { n: 'CCTV-风云音乐', pid: '600099660' },
        { n: 'CCTV-兵器科技', pid: '600099649' },
        { n: 'CCTV-风云足球', pid: '600099636' },
        { n: 'CCTV-高尔夫', pid: '600099659' },
        { n: 'CCTV-女性时尚', pid: '600099650' },
        { n: 'CCTV-文化精品', pid: '600099653' },
        { n: 'CCTV-台球', pid: '600099652' },
        { n: 'CCTV-电视指南', pid: '600099656' },
        { n: 'CCTV-卫生健康', pid: '600099651' },
        { n: '--- 卫视频道 ---', pid: null },
        { n: '北京卫视', pid: '600002309' },
        { n: '江苏卫视', pid: '600002521' },
        { n: '东方卫视', pid: '600002483' },
        { n: '浙江卫视', pid: '600002520' },
        { n: '湖南卫视', pid: '600002475' },
        { n: '湖北卫视', pid: '600002508' },
        { n: '广东卫视', pid: '600002485' },
        { n: '广西卫视', pid: '600002509' },
        { n: '黑龙江卫视', pid: '600002498' },
        { n: '海南卫视', pid: '600002506' },
        { n: '重庆卫视', pid: '600002531' },
        { n: '深圳卫视', pid: '600002481' },
        { n: '四川卫视', pid: '600002516' },
        { n: '河南卫视', pid: '600002525' },
        { n: '东南卫视', pid: '600002484' },
        { n: '贵州卫视', pid: '600002490' },
        { n: '江西卫视', pid: '600002503' },
        { n: '辽宁卫视', pid: '600002505' },
        { n: '安徽卫视', pid: '600002532' },
        { n: '河北卫视', pid: '600002493' },
        { n: '山东卫视', pid: '600002513' },
        { n: '天津卫视', pid: '600152137' },
        { n: '吉林卫视', pid: '600190405' },
        { n: '陕西卫视', pid: '600190400' },
        { n: '宁夏卫视', pid: '600190737' },
        { n: '内蒙古卫视', pid: '600190401' },
        { n: '云南卫视', pid: '600190402' },
        { n: '山西卫视', pid: '600190407' },
        { n: '青海卫视', pid: '600190406' },
        { n: '西藏卫视', pid: '600190403' },
        { n: '新疆卫视', pid: '600152138' }
    ];
   
    GM_addStyle(`
        body.cctv-clean-mode > *:not(.cctv-clean-main):not(.cctv-list-container) {
            display: none !important;
        }
   
        .cctv-clean-main {
            display: flex !important;
            flex-direction: row !important;
            align-items: stretch !important;
            gap: 30px !important;
            width: 100% !important;
            height: 100vh !important;
            padding: 25px !important;
            box-sizing: border-box !important;
            background: linear-gradient(145deg, #1a202c 0%, #2d3748 50%, #4a5568 100%) !important;
            perspective: 1200px !important;
            transform-style: preserve-3d !important;
        }
   
        .cctv-video-card {
            flex: 2.5 1 auto !important;
            background: linear-gradient(145deg, #000000 0%, #111827 100%) !important;
            border-radius: 20px !important;
            box-shadow: 
                0 20px 40px rgba(0,0,0,0.6),
                0 30px 60px rgba(0,0,0,0.4),
                inset 0 0 20px rgba(255,255,255,0.1) !important;
            overflow: hidden !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            border: 1px solid rgba(255,255,255,0.2) !important;
            min-width: 0 !important;
            max-width: 80vw !important;
            transform-style: preserve-3d !important;
            position: relative !important;
            margin: 0 auto !important;
            aspect-ratio: 16/9 !important;
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
            transform: translateZ(0) scale(1);
        }
        .cctv-video-card:hover {
            transform: translateZ(20px) scale(1.01) !important;
            box-shadow: 
                0 25px 50px rgba(0,0,0,0.7),
                0 35px 70px rgba(0,0,0,0.5),
                inset 0 0 25px rgba(255,255,255,0.15) !important;
        }
        .cctv-video-card::before {
            content: '' !important;
            position: absolute !important;
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            border-radius: 18px !important;
            border: 1px solid rgba(255,255,255,0.1) !important;
            pointer-events: none !important;
        }
   
        body:not(.yangshipin-layout) .cctv-video-card {
            height: 100% !important;
        }
   
        .yangshipin-layout .cctv-clean-main {
            padding: 20px 40px !important;
            gap: 30px !important;
        }
   
        .yangshipin-layout .cctv-video-spacer {
            flex: 1.2 !important;
            min-width: 40px !important;
        }
   
        .yangshipin-layout .cctv-video-card {
            flex: 3 1 auto !important;
            max-width: 80vw !important;
            width: auto !important;
            min-width: 0 !important;
            margin: 0 auto !important;
            height: auto !important;
            aspect-ratio: 16/9 !important;
        }
   
        .cctv-video-spacer {
            flex: 1 !important;
            min-width: 0 !important;
        }
   
        .cctv-video-wrap {
            width: 100% !important;
            height: 100% !important;
            display: flex !important;
            align-items: stretch !important;
            justify-content: center !important;
            background: #000 !important;
            overflow: hidden !important;
        }
   
        .cctv-video-wrap video,
        .cctv-video-wrap canvas,
        .cctv-video-wrap iframe {
            width: 100% !important;  /* 恢复原始宽度 */
            height: 100% !important;
            object-fit: contain !important;  /* 保持比例并完整显示 */
            object-position: center !important;
            /* 移除偏移,视频会自动居中 */
        }
   
        .cctv-video-wrap > div,
        .cctv-video-wrap > * {
            width: 100% !important;
            height: 100% !important;
        }
   
        .cctv-list-container {
            position: fixed !important;
            right: -180px !important;  /* 只隐藏菜单部分 */
            z-index: 999999 !important;
            display: flex !important;
            flex-direction: row !important;
            transition: right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
            overflow: visible !important;
            width: 222px !important;
        }
   
        .cctv-list-container:hover {
            right: 0 !important;
        }
   
        .cctv-list-card {
            width: 180px !important;
            height: 100% !important;
            background: linear-gradient(145deg, rgba(15, 23, 42, 0.98) 0%, rgba(30, 41, 59, 0.95) 100%) !important;
            backdrop-filter: blur(25px) saturate(200%) !important;
            -webkit-backdrop-filter: blur(25px) saturate(200%) !important;
            border-radius: 0 24px 24px 0 !important;
            box-shadow: 
                -10px 0 40px rgba(0,0,0,0.6),
                inset 1px 0 0 rgba(255,255,255,0.15),
                inset -3px 0 12px rgba(0,0,0,0.4) !important;
            overflow: hidden !important;
            display: flex !important;
            flex-direction: column !important;
            border: 1px solid rgba(255,255,255,0.25) !important;
            border-left: none !important;
            transform: perspective(1000px) rotateY(-5deg) translateZ(10px) !important;
            transform-origin: left center !important;
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
        }
        .cctv-list-container:hover .cctv-list-card {
            transform: perspective(1000px) rotateY(0deg) !important;
            box-shadow: 
                -5px 0 25px rgba(0,0,0,0.4),
                inset 1px 0 0 rgba(255,255,255,0.1) !important;
        }
   
        .cctv-list-tab {
            width: 42px !important;
            background: linear-gradient(180deg, rgba(99, 179, 255, 0.95) 0%, rgba(59, 130, 246, 0.9) 50%, rgba(37, 99, 235, 0.85) 100%) !important;
            color: #fff !important;
            font-size: 14px !important;
            font-weight: 700 !important;
            writing-mode: vertical-rl !important;
            letter-spacing: 4px !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            cursor: pointer !important;
            border-radius: 12px 0 0 12px !important;
            box-shadow: -5px 0 25px rgba(59, 130, 246, 0.4), inset 0 1px 0 rgba(255,255,255,0.3) !important;
            flex-shrink: 0 !important;
            border: 1px solid rgba(255,255,255,0.3) !important;
            border-right: none !important;
            height: 100% !important;
            transition: all 0.3s ease !important;
            text-shadow: 0 1px 3px rgba(0,0,0,0.4) !important;
        }
        .cctv-list-tab:hover {
            background: linear-gradient(180deg, rgba(120, 200, 255, 0.95) 0%, rgba(79, 150, 255, 0.9) 50%, rgba(47, 119, 245, 0.85) 100%) !important;
            box-shadow: -5px 0 30px rgba(59, 130, 246, 0.5), inset 0 1px 0 rgba(255,255,255,0.4) !important;
        }
   
        .cctv-list-card-header {
            padding: 12px 16px !important;
            font-size: 14px !important;
            font-weight: 600 !important;
            color: rgba(255,255,255,0.95) !important;
            border-bottom: 1px solid rgba(255,255,255,0.12) !important;
            background: rgba(30, 41, 59, 0.4) !important;
            flex-shrink: 0 !important;
            text-align: center !important;
            text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
        }
   
        .cctv-platform-switch {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            gap: 8px !important;
            padding: 10px 16px !important;
            border-bottom: 1px solid rgba(255,255,255,0.1) !important;
            background: rgba(15, 23, 42, 0.3) !important;
        }
 
        .cctv-platform-switch-btn {
            flex: 1 !important;
            padding: 8px 10px !important;
            border: 1px solid rgba(255,255,255,0.18) !important;
            border-radius: 8px !important;
            background: rgba(30, 41, 59, 0.6) !important;
            color: rgba(255,255,255,0.9) !important;
            font-size: 12px !important;
            font-weight: 500 !important;
            text-decoration: none !important;
            text-align: center !important;
            cursor: pointer !important;
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
            position: relative !important;
            overflow: hidden !important;
            backdrop-filter: blur(8px) !important;
        }
 
        .cctv-platform-switch-btn::before {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            background: linear-gradient(135deg, rgba(0,212,255,0.15) 0%, transparent 50%, rgba(0,212,255,0.08) 100%) !important;
            opacity: 0 !important;
            transition: opacity 0.2s ease !important;
        }
 
        .cctv-platform-switch-btn:hover {
            background: rgba(255,255,255,0.15) !important;
            border-color: rgba(0,212,255,0.5) !important;
            color: #00d4ff !important;
            transform: translateY(-1px) !important;
            box-shadow: 0 2px 8px rgba(0,212,255,0.2) !important;
        }
 
        .cctv-platform-switch-btn:hover::before {
            opacity: 1 !important;
        }
 
        .cctv-platform-switch-btn:active {
            transform: translateY(0) scale(0.98) !important;
        }
 
        .cctv-list-card-body {
            flex: 1 !important;
            overflow-y: auto !important;
            scrollbar-width: none !important;
            padding: 4px 8px !important;
        }
        .cctv-list-card-body::-webkit-scrollbar {
            display: none !important;
        }
   
        .cctv-list-card-body a {
            display: block !important;
            padding: 6px 12px !important;
            margin: 2px 0 !important;
            border-radius: 10px !important;
            color: rgba(255,255,255,0.9) !important;
            text-decoration: none !important;
            font-size: 13px !important;
            line-height: 1.3 !important;
            transition: all 0.2s ease !important;
        }
   
        .cctv-list-card-body a:hover {
            background: rgba(59, 130, 246, 0.15) !important;
            color: #fff !important;
            transform: translateX(3px) !important;
        }
   
        .cctv-list-card-body a.cctv-active {
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.25) 0%, rgba(37, 99, 235, 0.2) 100%) !important;
            color: #fff !important;
            border-left: 3px solid #3b82f6 !important;
            padding-left: 9px !important;
            font-weight: 600 !important;
            box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2) !important;
        }
   
        html, body {
            margin: 0 !important;
            padding: 0 !important;
            width: 100% !important;
            height: 100% !important;
            overflow: hidden !important;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        }
          
        /* 确保央视频区域鼠标指针可见 */
        .yangshipin-layout .cctv-video-card,
        .yangshipin-layout .cctv-video-wrap,
        .yangshipin-layout .cctv-video-wrap video {
            cursor: default !important;
        }
          
        /* 鼠标悬停时显示指针手型 */
        .yangshipin-layout .cctv-video-card:hover,
        .yangshipin-layout .cctv-video-wrap:hover {
            cursor: pointer !important;
        }

        /* 背景区域显示标准鼠标指针 */
        .cctv-clean-main {
            cursor: default !important;
        }
    `);
   
    // ────────────────────────────── CCTV 专用 ──────────────────────────────
   
    function findCCTVVideoColumn() {
        const video = document.querySelector('video');
        if (!video) return null;
   
        let el = video.parentElement;
        const vw = window.innerWidth;
        const vh = window.innerHeight;
        let count = 0;
   
        while (el && el !== document.body && count < 10) {
            const rect = el.getBoundingClientRect();
            if (rect.width > vw * 0.35 && rect.height > vh * 0.35) {
                return el;
            }
            el = el.parentElement;
            count++;
        }
        return video.parentElement || null;
    }
   
    function applyCCTVLayout() {
        if (document.querySelector('.cctv-clean-main')) return;
   
        const videoColumn = findCCTVVideoColumn();
        if (!videoColumn) return;
   
        let mainContainer = videoColumn.parentElement;
        while (mainContainer && mainContainer !== document.body) {
            const children = Array.from(mainContainer.children).filter(c => c.offsetWidth > 0);
            if (children.length >= 2) break;
            mainContainer = mainContainer.parentElement;
        }
        if (!mainContainer || mainContainer === document.body) mainContainer = document.body;
   
        mainContainer.classList.add('cctv-clean-main');
        videoColumn.classList.add('cctv-video-card');
   
        if (!videoColumn.querySelector('.cctv-video-wrap')) {
            const wrap = document.createElement('div');
            wrap.className = 'cctv-video-wrap';
            while (videoColumn.firstChild) {
                wrap.appendChild(videoColumn.firstChild);
            }
            videoColumn.appendChild(wrap);
        }
   
        const listContainer = document.createElement('div');
        listContainer.className = 'cctv-list-container';
   
        const listTab = document.createElement('div');
        listTab.className = 'cctv-list-tab';
        listTab.textContent = 'CCTV频道列表      双击视频全屏 ';
   
        const listCard = document.createElement('div');
        listCard.className = 'cctv-list-card';
        listCard.innerHTML = '<div class="cctv-list-card-header">频道列表</div><div class="cctv-platform-switch"><a href="https://www.yangshipin.cn/tv/" class="cctv-platform-switch-btn">跳转央视频</a></div><div class="cctv-list-card-body"></div>';
   
        const body = listCard.querySelector('.cctv-list-card-body');
        const curPath = location.pathname.replace(/\/$/, '').toLowerCase();
   
        CHANNELS.forEach(channel => {
            const a = document.createElement('a');
            a.href = new URL(channel.u, location.origin).href;
            a.textContent = channel.n;
            const linkPath = new URL(a.href).pathname.replace(/\/$/, '').toLowerCase();
            if (curPath === linkPath || curPath.startsWith(linkPath + '/')) {
                a.classList.add('cctv-active');
            }
            body.appendChild(a);
        });
   
        listContainer.appendChild(listTab);
        listContainer.appendChild(listCard);
        document.body.appendChild(listContainer);
   
        const spacerLeft = document.createElement('div');
        spacerLeft.className = 'cctv-video-spacer';
        const spacerRight = document.createElement('div');
        spacerRight.className = 'cctv-video-spacer';
   
        videoColumn.before(spacerLeft);
        videoColumn.after(spacerRight);
   
        Array.from(mainContainer.children).forEach(child => {
            if (![spacerLeft, videoColumn, spacerRight].includes(child)) {
                child.style.display = 'none';
            }
        });
   
        document.body.prepend(mainContainer);
        document.body.classList.add('cctv-clean-mode');
  
        const videoWrap = videoColumn.querySelector('.cctv-video-wrap');
        if (videoWrap) {
            videoWrap.addEventListener('dblclick', () => {
                const video = videoWrap.querySelector('video');
                if (video) {
                    if (document.fullscreenElement) {
                        document.exitFullscreen();
                    } else {
                        videoWrap.requestFullscreen();
                    }
                }
            });
        }
  
        const syncList = () => {
            const card = document.querySelector('.cctv-video-card');
            const list = document.querySelector('.cctv-list-container');
            if (card && list) {
                const rect = card.getBoundingClientRect();
                list.style.top = rect.top + 'px';
                list.style.height = rect.height + 'px';
            }
        };
        syncList();
        window.addEventListener('resize', syncList);
    }
   
    // ────────────────────────────── 央视频 专用 ──────────────────────────────
   
    function findYangVideoColumn() {
        const video = document.querySelector('video');
        if (!video) return null;
   
        let el = video.parentElement;
        const vw = window.innerWidth;
        const vh = window.innerHeight;
        let count = 0;
   
        while (el && el !== document.body && count < 12) {
            const rect = el.getBoundingClientRect();
            const className = (el.className || '').toLowerCase();
            if ((className.includes('player') || className.includes('video') || className.includes('container')) &&
                rect.width > vw * 0.4 && rect.height > vh * 0.35) {
                return el;
            }
            el = el.parentElement;
            count++;
        }
        return video.parentElement || null;
    }
   
    function applyYangLayout() {
        if (document.querySelector('.cctv-clean-main')) return;
        document.body.classList.add('yangshipin-layout');
   
        const videoColumn = findYangVideoColumn();
        if (!videoColumn) return;
   
        let mainContainer = videoColumn.parentElement;
        while (mainContainer && mainContainer !== document.body) {
            const children = Array.from(mainContainer.children).filter(c => c.offsetWidth > 0);
            if (children.length >= 2) break;
            mainContainer = mainContainer.parentElement;
        }
        if (!mainContainer || mainContainer === document.body) mainContainer = document.body;
   
        mainContainer.classList.add('cctv-clean-main');
        videoColumn.classList.add('cctv-video-card');
   
        if (!videoColumn.querySelector('.cctv-video-wrap')) {
            const wrap = document.createElement('div');
            wrap.className = 'cctv-video-wrap';
            while (videoColumn.firstChild) {
                wrap.appendChild(videoColumn.firstChild);
            }
            videoColumn.appendChild(wrap);
        }
   
        const listContainer = document.createElement('div');
        listContainer.className = 'cctv-list-container';
   
        const listTab = document.createElement('div');
        listTab.className = 'cctv-list-tab';
        listTab.textContent = '央视频频道      双击视频全屏';
   
        const listCard = document.createElement('div');
        listCard.className = 'cctv-list-card';
        listCard.innerHTML = '<div class="cctv-list-card-header">央视频频道</div><div class="cctv-platform-switch"><a href="https://tv.cctv.com/live/" class="cctv-platform-switch-btn">跳转CCTV</a></div><div class="cctv-list-card-body"></div>';
   
        const body = listCard.querySelector('.cctv-list-card-body');
        const currentUrl = location.href.toLowerCase();
   
        YANG_CHANNELS.forEach(item => {
            if (item.pid === null) {
                const divider = document.createElement('div');
                divider.style.cssText = 'padding: 6px 10px; font-size: 13px; color: rgba(255,255,255,0.7); font-weight: 600; margin: 8px 0 4px;';
                divider.textContent = item.n;
                body.appendChild(divider);
            } else {
                const a = document.createElement('a');
                a.href = '/tv/home?pid=' + item.pid;
                a.textContent = item.n;
                if (currentUrl.includes('pid=' + item.pid)) {
                    a.classList.add('cctv-active');
                }
                body.appendChild(a);
            }
        });
   
        listContainer.appendChild(listTab);
        listContainer.appendChild(listCard);
        document.body.appendChild(listContainer);
   
        const spacerLeft = document.createElement('div');
        spacerLeft.className = 'cctv-video-spacer';
        const spacerRight = document.createElement('div');
        spacerRight.className = 'cctv-video-spacer';
   
        videoColumn.before(spacerLeft);
        videoColumn.after(spacerRight);
   
        Array.from(mainContainer.children).forEach(child => {
            if (![spacerLeft, videoColumn, spacerRight].includes(child)) {
                child.style.display = 'none';
            }
        });
   
        document.body.prepend(mainContainer);
        document.body.classList.add('cctv-clean-mode');
   
         // 添加双击全屏功能(央视频)
        const videoWrap = videoColumn.querySelector('.cctv-video-wrap');
        if (videoWrap) {
            videoWrap.addEventListener('dblclick', () => {
                const video = videoWrap.querySelector('video');
                if (video) {
                    if (document.fullscreenElement) {
                        document.exitFullscreen();
                    } else {
                        videoWrap.requestFullscreen();
                    }
                }
            });
        }
        const syncList = () => {
            const card = document.querySelector('.cctv-video-card');
            const list = document.querySelector('.cctv-list-container');
            if (card && list) {
                const rect = card.getBoundingClientRect();
                list.style.top = rect.top + 'px';
                list.style.height = rect.height + 'px';
            }
        };
        syncList();
        window.addEventListener('resize', syncList);
    }
   
    function tryApplyLayout() {
        const host = location.hostname.toLowerCase();
        if (host.includes('tv.cctv.com')) {
            applyCCTVLayout();
        } else if (host.includes('yangshipin.cn')) {
            applyYangLayout();
        }
    }
   
    if (document.readyState === 'complete') {
        setTimeout(tryApplyLayout, 1800);
    } else {
        window.addEventListener('load', () => {
            setTimeout(tryApplyLayout, 1800);
        });
    }
   
    const observer = new MutationObserver(() => {
        if (!document.querySelector('.cctv-clean-main') && document.querySelector('video')) {
            tryApplyLayout();
        }
    });
   
    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });
   
})();






点评

第3个版本有现成的你制作的浏览器版本吗?  发表于 2026-2-25 19:22

免费评分

参与人数 127吾爱币 +121 热心值 +116 收起 理由
初夏小雨 + 1 + 1 我很赞同!
laaland + 1 + 1 谢谢@Thanks!
homejun + 1 + 1 谢谢@Thanks!
fsjsyg + 1 + 1 谢谢@Thanks!
catwl820 + 1 + 1 我很赞同!太适合用电脑的老年人了
foxcdwapj + 1 + 1 热心回复!
6688best + 1 + 1 谢谢@Thanks!
捉泥鳅的开心熊 + 1 + 1 谢谢@Thanks!
Cleverwwh + 1 + 1 我很赞同!
mytomsummer + 1 + 1 我很赞同!
lvzhiqi + 1 + 1 谢谢@Thanks!
99248688 + 1 + 1 谢谢@Thanks!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
锂电是信仰 + 1 + 1 热心回复!
TXS178 + 1 + 1 我很赞同!
zhuiaaa + 1 + 1 谢谢@Thanks!
此地无银三百两 + 1 + 1 热心回复!
zhu1979 + 1 + 1 谢谢@Thanks!
远音 + 1 谢谢@Thanks!
ngfc + 1 我很赞同!
greenmood + 1 热心回复!
qinluezhew3 + 1 + 1 谢谢@Thanks!
18505332401 + 1 + 1 谢谢@Thanks!
dengyuedong + 1 + 1 谢谢@Thanks!
默敝诩 + 1 + 1 谢谢@Thanks!
apor999 + 1 + 1 我很赞同!
fuming2023 + 1 + 1 谢谢@Thanks!
w19890614 + 1 + 1 谢谢@Thanks!
damocles1985 + 1 + 1 谢谢@Thanks!
zhijiandeyanhuo + 1 + 1 我很赞同!
icehoo + 1 + 1 谢谢@Thanks!
liboys + 1 + 1 谢谢@Thanks!
handafang + 1 + 1 谢谢@Thanks!
yubao0205 + 1 我很赞同!
zjjxyz + 1 + 1 我很赞同!
wang82530 + 1 + 1 鼓励转贴优秀软件安全工具和文档!
52pojieplayer + 1 谢谢@Thanks!
sadman1119 + 1 + 1 我很赞同!
SansuidouEr + 1 + 1 谢谢@Thanks!
dahan531 + 1 + 1 我很赞同!
wxf2288 + 1 谢谢@Thanks!
yys5161 + 1 + 1 我很赞同!
风风魔王 + 1 + 1 我很赞同!
mmmodern + 1 我很赞同!
xiaozhuge + 1 谢谢@Thanks!
voila。 + 1 + 1 热心回复!
jjkl + 1 + 1 谢谢@Thanks!
pntvmin + 1 + 1 谢谢@Thanks!
dajun2068 + 1 + 1 谢谢@Thanks!
myoudk + 1 + 1 我很赞同!
Voccoo + 1 + 1 我很赞同!
waynewange + 1 + 1 用心讨论,共获提升!
woxiangyaozhuce + 1 谢谢@Thanks!
李艾克 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
wddddd + 1 + 1 谢谢@Thanks!
sc139 + 1 + 1 我很赞同!
一只梦蝶 + 1 + 1 我很赞同!
resu + 1 + 1 我很赞同!
zhaomingzhi + 1 + 1 谢谢@Thanks!
zou003 + 1 + 1 我很赞同!
luoxy3 + 2 + 1 谢谢@Thanks!
momogg + 1 + 1 我很赞同!
theStyx + 1 谢谢@Thanks!
baiseyuyi + 1 + 1 谢谢@Thanks!
ColorExists + 1 + 1 谢谢@Thanks!
buran68 + 1 + 1 热心回复!
鱼鱼岛 + 1 我很赞同!
nojon + 1 + 1 谢谢@Thanks!
jie520yun + 1 + 1 我很赞同!
CC520CC + 1 + 1 谢谢@Thanks!
ichenqing + 1 + 1 电视机上能看吗
唐小样儿 + 1 + 1 我很赞同!
成事丶 + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
zjh106 + 1 + 1 谢谢@Thanks!
aqrookie + 1 + 1 谢谢@Thanks!
Karry5 + 1 + 1 谢谢@Thanks!
squirtlover + 1 + 1 谢谢@Thanks!
tvrcfdfe + 1 + 1 热心回复!
rebirthboy + 1 我很赞同!
天之牙2012 + 1 + 1
WJF12321 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
zhyasi + 1 + 1 我很赞同!
Eter永恒 + 1 + 1 热心回复!
meet52 + 1 + 1 我很赞同!
hncs2008 + 1 + 1 谢谢@Thanks!
fishu + 1 谢谢@Thanks!
yiqibufenli + 1 + 1 我很赞同!
pscpscpsc + 1 谢谢@Thanks!
MayMayHai8971 + 1 + 1 用心讨论,共获提升!
zj_tj + 1 + 1 我很赞同!
ikerli + 1 + 1 谢谢@Thanks!
wqx520 + 1 + 1 谢谢@Thanks!
imims + 1 谢谢@Thanks!
wansir + 1 + 1 谢谢@Thanks!
jnzj4811 + 1 + 1 谢谢@Thanks!
huajin2016 + 1 + 1 用心讨论,共获提升!
sois + 1 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
yurui152 + 1 + 1 热心回复!
lkl2425572 + 1 + 1 做个央视频的有地方台
wu_yang007 + 1 谢谢@Thanks!

查看全部评分

本帖被以下淘专辑推荐:

  • · 实用|主题: 473, 订阅: 24
  • · 技巧|主题: 15, 订阅: 0

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

华昕 发表于 2026-2-22 22:42
本帖最后由 华昕 于 2026-2-25 15:03 编辑

我用AI在楼主更新版的基础上改了个,台列表自动隐藏,鼠标移动右边时显示,移开隐藏,视频默认网页全屏:
QQ图片20260222211656.png

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         CCTV节目过滤脚本
// @namespace    http://tampermonkey.net/
// @version      8.8
// @description  强制视频全屏,彻底物理移除所有菜单、二维码及干扰项,列表紧凑悬浮
// @AuThor       User
// @match        https://tv.cctv.com/live/*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    const CHANNELS = [
        { n: 'CCTV-1 综合', u: '/live/cctv1/' }, { n: 'CCTV-2 财经', u: '/live/cctv2/' },
        { n: 'CCTV-3 综艺', u: '/live/cctv3/' }, { n: 'CCTV-4 中文国际', u: '/live/cctv4/' },
        { n: 'CCTV-5 体育', u: '/live/cctv5/' }, { n: 'CCTV-5+ 体育赛事', u: '/live/cctv5plus/' },
        { n: 'CCTV-6 电影', u: '/live/cctv6/' }, { n: 'CCTV-7 国防军事', u: '/live/cctv7/' },
        { n: 'CCTV-8 电视剧', u: '/live/cctv8/' }, { n: 'CCTV-9 纪录', u: '/live/cctvjilu/' },
        { n: 'CCTV-10 科教', u: '/live/cctv10/' }, { n: 'CCTV-11 戏曲', u: '/live/cctv11/' },
        { n: 'CCTV-12 社会与法', u: '/live/cctv12/' }, { n: 'CCTV-13 新闻', u: '/live/cctv13/' },
        { n: 'CCTV-14 少儿', u: '/live/cctvchild/' }, { n: 'CCTV-15 音乐', u: '/live/cctv15/' },
        { n: 'CCTV-16 奥林匹克', u: '/live/cctv16/' }, { n: 'CCTV-17 农业农村', u: '/live/cctv17/' }
    ];

    GM_addStyle(`
        /* 1. 基础环境锁定 */
        body, html { background: #000 !important; overflow: hidden !important; margin: 0 !important; }
        
        /* 2. 视频强制置顶全屏,覆盖一切 */
        video, canvas, #player_page_main, .player_video, .video_left {
            position: fixed !important;
            top: 0 !important;
            left: 0 !important;
            width: 100vw !important;
            height: 100vh !important;
            z-index: 999998 !important;
            background: #000 !important;
            object-fit: contain !important;
        }

        /* 3. 频道列表样式:紧凑且层级最高 */
        .cctv-compact-list {
            position: fixed !important;
            right: -180px;
            top: 50%;
            transform: translateY(-50%);
            width: 165px;
            background: rgba(255, 255, 255, 0.98) !important;
            border-radius: 12px 0 0 12px !important;
            box-shadow: -10px 0 30px rgba(0,0,0,0.8);
            display: flex !important;
            flex-direction: column !important;
            z-index: 2147483647 !important;
            transition: right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
            border: 1px solid #ccc;
            padding: 5px 0;
        }
        .cctv-compact-list.show { right: 0 !important; }
        .list-item {
            display: block !important;
            padding: 5px 12px !important;
            margin: 1px 4px !important;
            color: #333 !important;
            text-decoration: none !important;
            font-size: 12px !important;
            border-radius: 4px !important;
            transition: 0.1s;
        }
        .list-item:hover { background: #f0f0f0; color: #ff0000 !important; }
        .list-item.active { background: #ff0000 !important; color: #fff !important; font-weight: bold; }

        /* 强制隐藏所有截图中的干扰元素及其容器 */
        .g-header, .top_nav, .header, .nav, .menu_wrap, .top_wrap, .cnt_share, 
        .qr_code, .phone_look, .share_box, .footer, #page_bottom, .video_right,
        [class*="header"], [id*="header"], [class*="qr_code"], [class*="phone_visit"] {
            display: none !important;
            opacity: 0 !important;
            visibility: hidden !important;
        }
    `);

    // 物理清道夫:精准识别并删除包含指定文字或ID的干扰项
    function physicalCleaner() {
        const keywords = ["首页", "时政", "地方", "乡村振兴", "手机访问", "二维码", "节目官网"];
        
        // 1. 根据关键词移除元素
        const allDivs = document.querySelectorAll('div, header, nav, section, a, span');
        allDivs.forEach(el => {
            if (keywords.some(kw => el.innerText && el.innerText.includes(kw))) {
                // 排除我们的自定义列表和视频标签本身
                if (!el.querySelector('video') && !el.closest('.cctv-compact-list')) {
                    el.remove();
                }
            }
        });

        // 2. 根据常见的顽固 ID 移除
        const garbageIds = ['page_bottom', 'footer', 'header_wrap', 'top_nav', 'qr_code_pc', 'phone_visit'];
        garbageIds.forEach(id => {
            const el = document.getElementById(id);
            if (el) el.remove();
        });
    }

    function setupList() {
        if (document.querySelector('.cctv-compact-list')) return;
        const list = document.createElement('div');
        list.className = 'cctv-compact-list';
        CHANNELS.forEach(c => {
            const a = document.createElement('a');
            a.className = 'list-item';
            a.href = c.u;
            a.textContent = c.n;
            if (window.location.pathname.includes(c.u)) a.className += ' active';
            list.appendChild(a);
        });
        document.body.appendChild(list);

        document.addEventListener('mousemove', (e) => {
            const w = window.innerWidth;
            if (e.clientX > w - 35) list.classList.add('show');
            else if (e.clientX < w - 180) list.classList.remove('show');
        });
    }

    // 持续清扫,确保极致纯净
    setupList();
    setInterval(() => {
        physicalCleaner();
        const v = document.querySelector('video');
        if (v) {
            v.style.setProperty('position', 'fixed', 'important');
            v.style.setProperty('z-index', '999998', 'important');
            v.style.setProperty('top', '0', 'important');
        }
    }, 1000);

})();


央视频网址72频道版本,与上面一样,频道列表自动隐藏,分三栏鼠标图标。

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name         央视频直播纯净版 (72频道三栏完美版)
// @namespace    http://tampermonkey.net/
// @version      1.6
// @author       User
// @match        https://www.yangshipin.cn/tv/home*
// @grant        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    const CHANNELS = [
        { n: 'CCTV-1 综合', id: '600001859' }, { n: 'CCTV-2 财经', id: '600001800' },
        { n: 'CCTV-3 综艺', id: '600001801' }, { n: 'CCTV-4 中文国际', id: '600001814' },
        { n: 'CCTV-5 体育', id: '600001818' }, { n: 'CCTV-5+ 体育赛事', id: '600001817' },
        { n: 'CCTV-6 电影', id: '600108442' }, { n: 'CCTV-7 国防军事', id: '600004092' },
        { n: 'CCTV-8 电视剧', id: '600001803' }, { n: 'CCTV-9 纪录', id: '600004078' },
        { n: 'CCTV-10 科教', id: '600001805' }, { n: 'CCTV-11 戏曲', id: '600001806' },
        { n: 'CCTV-12 社会与法', id: '600001807' }, { n: 'CCTV-13 新闻', id: '600001811' },
        { n: 'CCTV-14 少儿', id: '600001809' }, { n: 'CCTV-15 音乐', id: '600001815' },
        { n: 'CCTV-16 奥林匹克', id: '600098637' }, { n: 'CCTV-16 4k', id: '600099502' },
        { n: 'CCTV-17 农业农村', id: '600001810' }, { n: 'CCTV-4K 超高清', id: '600002264' },
        { n: 'CCTV-8K 超高清', id: '600156816' }, { n: 'CGTN', id: '600014550' },
        { n: 'CGTN法语', id: '600084704' }, { n: 'CGTN俄语', id: '600084758' },
        { n: 'CGTN阿拉伯语', id: '600084782' }, { n: 'CGTN西班牙语', id: '600084744' },
        { n: 'CGTN外语纪录', id: '600084781' }, { n: 'CCTV-风云剧场', id: '600099658' },
        { n: 'CCTV-第一剧场', id: '600099655' }, { n: 'CCTV-怀旧剧场', id: '600099620' },
        { n: 'CCTV-世界地理', id: '600099637' }, { n: 'CCTV-风云音乐', id: '600099660' },
        { n: 'CCTV-兵器科技', id: '600099649' }, { n: 'CCTV-风云足球', id: '600099636' },
        { n: 'CCTV-高尔夫', id: '600099659' }, { n: 'CCTV-女性时尚', id: '600099650' },
        { n: 'CCTV-文化精品', id: '600099653' }, { n: 'CCTV-台球', id: '600099652' },
        { n: 'CCTV-电视指南', id: '600099656' }, { n: 'CCTV-卫生健康', id: '600099651' },
        { n: '北京卫视', id: '600002309' }, { n: '江苏卫视', id: '600002521' },
        { n: '东方卫视', id: '600002483' }, { n: '浙江卫视', id: '600002520' },
        { n: '湖南卫视', id: '600002475' }, { n: '湖北卫视', id: '600002508' },
        { n: '广东卫视', id: '600002485' }, { n: '广西卫视', id: '600002509' },
        { n: '黑龙江卫视', id: '600002498' }, { n: '海南卫视', id: '600002506' },
        { n: '重庆卫视', id: '600002531' }, { n: '深圳卫视', id: '600002481' },
        { n: '四川卫视', id: '600002516' }, { n: '河南卫视', id: '600002525' },
        { n: '福建东南', id: '600002484' }, { n: '贵州卫视', id: '600002490' },
        { n: '江西卫视', id: '600002503' }, { n: '辽宁卫视', id: '600002505' },
        { n: '安徽卫视', id: '600002532' }, { n: '河北卫视', id: '600002493' },
        { n: '山东卫视', id: '600002513' }, { n: '天津卫视', id: '600152137' },
        { n: '吉林卫视', id: '600190405' }, { n: '陕西卫视', id: '600190400' },
        { n: '宁夏卫视', id: '600190737' }, { n: '内蒙古', id: '600190401' },
        { n: '云南卫视', id: '600190402' }, { n: '山西卫视', id: '600190407' },
        { n: '青海卫视', id: '600190406' }, { n: '西藏卫视', id: '600190403' },
        { n: '中国教育1', id: '600171827' }, { n: '新疆卫视', id: '600152138' }
    ];

    GM_addStyle(`
        body, html { background: #000 !important; overflow: hidden !important; margin: 0 !important; }
        video, .video-player-container, #player-container {
            position: fixed !important; top: 0 !important; left: 0 !important;
            width: 100vw !important; height: 100vh !important;
            z-index: 999998 !important; background: #000 !important;
        }
        .header-wrap, .side-bar, .download-app, .footer-wrap, .right-section, 
        [class*="Guide"], [class*="Header"], [class*="Footer"] { display: none !important; }
        
        #custom-ysp-panel {
            position: fixed !important; right: -480px; top: 50%;
            transform: translateY(-50%); background: rgba(255, 255, 255, 0.98) !important;
            border-radius: 15px 0 0 15px !important; box-shadow: -15px 0 35px rgba(0,0,0,0.8);
            z-index: 2147483647 !important; transition: right 0.4s ease;
            padding: 12px; display: grid !important;
            grid-template-columns: repeat(3, 145px); gap: 2px 8px;
            max-height: 98vh; pointer-events: auto !important;
        }
        #custom-ysp-panel.show { right: 0 !important; }
        .list-item {
            display: block !important; padding: 3px 6px !important; color: #333 !important;
            text-decoration: none !important; font-size: 11px !important;
            border-radius: 4px !important; white-space: nowrap; cursor: pointer !important;
        }
        .list-item:hover { background: #f2f2f2; color: #ff0000 !important; }
        .list-item.active { background: #ff0000 !important; color: #fff !important; font-weight: bold; }
        html.force-hide-cursor, html.force-hide-cursor * { cursor: none !important; }
    `);

    let cursorTimer = null;
    let isPanelShown = false;

    function setCursor(visible) {
        document.documentElement.classList.toggle('force-hide-cursor', !visible);
    }

    function resetTimer() {
        setCursor(true);
        if (cursorTimer) clearTimeout(cursorTimer);
        cursorTimer = setTimeout(() => { if (!isPanelShown) setCursor(false); }, 3000);
    }

    function init() {
        if (document.getElementById('custom-ysp-panel')) return;
        const panel = document.createElement('div');
        panel.id = 'custom-ysp-panel';
        CHANNELS.forEach(c => {
            const el = document.createElement('div');
            el.className = 'list-item';
            el.textContent = c.n;
            el.onclick = (e) => { e.stopPropagation(); window.location.href = `https://www.yangshipin.cn/tv/home?pid=${c.id}`; };
            if (window.location.search.includes(c.id)) el.classList.add('active');
            panel.appendChild(el);
        });
        document.body.appendChild(panel);

        window.addEventListener('mousemove', (e) => {
            resetTimer();
            const w = window.innerWidth;
            if (e.clientX > w - 40) { panel.classList.add('show'); isPanelShown = true; setCursor(true); }
            else if (e.clientX < w - 460) { panel.classList.remove('show'); isPanelShown = false; }
        }, { capture: true });
    }

    init();
    resetTimer();
    setInterval(() => {
        init();
        const v = document.querySelector('video');
        if (v) v.style.setProperty('z-index', '999998', 'important');
        document.querySelectorAll('[class*="Close"], .close-icon').forEach(x => x.click());
    }, 1000);
})();

免费评分

参与人数 8吾爱币 +6 热心值 +7 收起 理由
zjjxyz + 1 + 1 我很赞同!
q110 + 1 我很赞同!
theStyx + 1 我很赞同!
xuelong911 + 1 + 1 我很赞同!
Hsing + 1 + 1 谢谢@Thanks!
8Kevin + 1 + 1 谢谢@Thanks!
honghu + 1 谢谢@Thanks!
遇见你 + 1 + 1 我很赞同!

查看全部评分

nojon 发表于 2026-2-24 09:52
renzhen1997 发表于 2026-2-24 18:12
nojon 发表于 2026-2-24 09:52
还是这个网址的频道最全
https://www.yangshipin.cn/tv/home

你这个好 画质更高清
lsbdx 发表于 2026-2-25 12:44
本帖最后由 lsbdx 于 2026-2-25 12:46 编辑
可以试试这个脚本

[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// [url=home.php?mod=space&uid=170990]@name[/url]          央视频
// [url=home.php?mod=space&uid=467642]@namespace[/url]     [url=http://tampermonkey.net/]http://tampermonkey.net/[/url]
// [url=home.php?mod=space&uid=1248337]@version[/url]       1.1
// @description   过滤央视频网页内容,只显示核心视频和右侧可滑出节目列表
// [url=home.php?mod=space&uid=686208]@AuThor[/url]        User
// [url=home.php?mod=space&uid=195849]@match[/url]         [url=https://www.yangshipin.cn/tv/]https://www.yangshipin.cn/tv/[/url]*
// [url=home.php?mod=space&uid=609072]@grant[/url]         GM_addStyle
// @grant         unsafeWindow
// ==/UserScript==

(function() {
    'use strict';

const CHANNELS = [
    // ===================== CCTV核心频道 =====================
    { n: 'CCTV1', u: '/tv/home?pid=600001859' },
    { n: 'CCTV2', u: '/tv/home?pid=600001800' },
    { n: 'CCTV3', u: '/tv/home?pid=600001801' },
    { n: 'CCTV4', u: '/tv/home?pid=600001814' },
    { n: 'CCTV5', u: '/tv/home?pid=600001818' },
    { n: 'CCTV5+', u: '/tv/home?pid=600001817' },
    { n: 'CCTV6', u: '/tv/home?pid=600108442' },
    { n: 'CCTV7', u: '/tv/home?pid=600004092' },
    { n: 'CCTV8', u: '/tv/home?pid=600001803' },
    { n: 'CCTV9', u: '/tv/home?pid=600004078' },
    { n: 'CCTV10', u: '/tv/home?pid=600001805' },
    { n: 'CCTV11', u: '/tv/home?pid=600001806' },
    { n: 'CCTV12', u: '/tv/home?pid=600001807' },
    { n: 'CCTV13', u: '/tv/home?pid=600001811' },
    { n: 'CCTV14', u: '/tv/home?pid=600001809' },
    { n: 'CCTV15', u: '/tv/home?pid=600001815' },
    { n: 'CCTV16-HD', u: '/tv/home?pid=600098637' },
    { n: 'CCTV16(4K)', u: '/tv/home?pid=600099502' },
    { n: 'CCTV17', u: '/tv/home?pid=600001810' },
    { n: 'CCTV4K', u: '/tv/home?pid=600002264' },
    { n: 'CCTV8K', u: '/tv/home?pid=600156816' },
    { n: 'CGTN', u: '/tv/home?pid=600014550' },
    { n: 'CGTN法语', u: '/tv/home?pid=600084704' },
    { n: 'CGTN俄语', u: '/tv/home?pid=600084758' },
    { n: 'CGTN阿拉伯语', u: '/tv/home?pid=600084782' },
    { n: 'CGTN西班牙语', u: '/tv/home?pid=600084744' },
    { n: 'CGTN外语纪录', u: '/tv/home?pid=600084781' },
    { n: 'CCTV风云剧场', u: '/tv/home?pid=600099658' },
    { n: 'CCTV第一剧场', u: '/tv/home?pid=600099655' },
    { n: 'CCTV怀旧剧场', u: '/tv/home?pid=600099620' },

    // ===================== 省级卫视(按你提供的顺序)=====================
    { n: '北京卫视', u: '/tv/home?pid=600002309' },
    { n: '江苏卫视', u: '/tv/home?pid=600002521' },
    { n: '东方卫视', u: '/tv/home?pid=600002483' },
    { n: '浙江卫视', u: '/tv/home?pid=600002520' },
    { n: '湖南卫视', u: '/tv/home?pid=600002475' },
    { n: '湖北卫视', u: '/tv/home?pid=600002508' },
    { n: '广东卫视', u: '/tv/home?pid=600002485' },
    { n: '广西卫视', u: '/tv/home?pid=600002509' },
    { n: '黑龙江', u: '/tv/home?pid=600002498' },
    { n: '海南卫视', u: '/tv/home?pid=600002506' },
    { n: '重庆卫视', u: '/tv/home?pid=600002531' },
    { n: '深圳卫视', u: '/tv/home?pid=600002481' },
    { n: '四川卫视', u: '/tv/home?pid=600002516' },
    { n: '河南卫视', u: '/tv/home?pid=600002525' },
    { n: '福建东南', u: '/tv/home?pid=600002484' },
    { n: '贵州卫视', u: '/tv/home?pid=600002490' },
    { n: '江西卫视', u: '/tv/home?pid=600002503' },
    { n: '辽宁卫视', u: '/tv/home?pid=600002505' },
    { n: '安徽卫视', u: '/tv/home?pid=600002532' },
    { n: '河北卫视', u: '/tv/home?pid=600002493' },
    { n: '山东卫视', u: '/tv/home?pid=600002513' },
    { n: '天津卫视', u: '/tv/home?pid=600152137' },
    { n: '吉林卫视', u: '/tv/home?pid=600190405' },
    { n: '陕西卫视', u: '/tv/home?pid=600190400' },
    { n: '宁夏卫视', u: '/tv/home?pid=600190737' },
    { n: '内蒙古', u: '/tv/home?pid=600190401' },
    { n: '云南卫视', u: '/tv/home?pid=600190402' },
    { n: '山西卫视', u: '/tv/home?pid=600190407' },
    { n: '青海卫视', u: '/tv/home?pid=600190406' },
    { n: '西藏卫视', u: '/tv/home?pid=600190403' },
    { n: '中国教育1', u: '/tv/home?pid=600171827' },
    { n: '新疆卫视', u: '/tv/home?pid=600152138' }
];

    // 核心样式(适配央视频页面结构)
    GM_addStyle(`
        /* 全局清理:保留核心容器 */
        body.yangshi-clean-mode > *:not(.yangshi-clean-main):not(.yangshi-list-container) {
            display: none !important;
        }

        /* 主布局:视频居中,两侧占位 */
        .yangshi-clean-main {
            display: flex !important;
            flex-direction: row !important;
            align-items: stretch !important;
            justify-content: center !important;
            gap: 24px !important;
            width: 100% !important;
            height: 100vh !important;
            padding: 20px !important;
            box-sizing: border-box !important;
            background: linear-gradient(145deg, #b8c2cc 0%, #9ca8b5 50%, #8a96a4 100%) !important;
        }

        /* 左侧视频卡片 - 16:9比例,消除黑边 */
        .yangshi-video-card {
            flex: 5 !important;
            align-self: stretch !important;
            min-width: 0 !important;
            background: linear-gradient(145deg, #b8c2cc 0%, #9ca8b5 50%, #8a96a4 100%) !important;
            border-radius: 16px !important;
            box-shadow: 0 12px 40px rgba(0,0,0,0.18), 0 6px 16px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08) !important;
            overflow: hidden !important;
            padding: 0 !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            border: 1px solid rgba(0,0,0,0.06) !important;
        }

        /* 16:9视频包装层 */
        .yangshi-video-wrap {
            flex: 0 0 auto !important;
            width: 100% !important;
            height: 100% !important;
            max-width: 100% !important;
            max-height: 100% !important;
            aspect-ratio: 16/9 !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            background: #000 !important;
        }

        .yangshi-video-wrap video, .yangshi-video-wrap canvas {
            width: 100% !important;
            height: 100% !important;
            object-fit: contain !important;
        }

        .yangshi-video-wrap > div, .yangshi-video-wrap > * {
            width: 100% !important;
            height: 100% !important;
        }

        /* 两侧占位 */
        .yangshi-video-spacer {
            flex: 1 !important;
            min-width: 0 !important;
        }

        /* 右侧可收缩频道列表 */
        .yangshi-list-container {
            position: fixed !important;
            right: -170px !important;
            z-index: 999999 !important;
            display: flex !important;
            flex-direction: row !important;
            transition: right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
        }

        .yangshi-list-container:hover {
            right: 0 !important;
        }

        .yangshi-list-card {
            width: 170px !important;
            height: 100% !important;
            background: #fff !important;
            border-radius: 0 16px 16px 0 !important;
            box-shadow: 8px 0 24px rgba(0,0,0,0.15) !important;
            overflow: hidden !important;
            display: flex !important;
            flex-direction: column !important;
            border: 1px solid rgba(0,0,0,0.06) !important;
            border-left: none !important;
        }

        .yangshi-list-tab {
            width: 40px !important;
            background: linear-gradient(180deg, #e53935 0%, #d32f2f 100%) !important; /* 央视频主色调 */
            color: #fff !important;
            font-size: 14px !important;
            font-weight: 700 !important;
            writing-mode: vertical-rl !important;
            letter-spacing: 4px !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            cursor: pointer !important;
            border-radius: 8px 0 0 8px !important;
            box-shadow: -4px 0 12px rgba(0,0,0,0.2) !important;
            flex-shrink: 0 !important;
            border: 2px solid rgba(255,255,255,0.3) !important;
            border-right: none !important;
            height: 100% !important;
        }

        .yangshi-list-card-header {
            padding: 8px 14px !important;
            font-size: 14px !important;
            font-weight: 600 !important;
            color: #1a1a2e !important;
            border-bottom: 1px solid #eee !important;
            background: #fafbfc !important;
            flex-shrink: 0 !important;
            text-align: center !important;
        }

        .yangshi-list-card-body {
            flex: 1 !important;
            overflow-y: auto !important;
            padding: 6px 10px !important;
        }

        .yangshi-list-card-body a {
            display: block !important;
            padding: 4px 10px !important;
            margin: 2px 0 !important;
            border-radius: 8px !important;
            color: #333 !important;
            text-decoration: none !important;
            font-size: 13px !important;
            line-height: 1.3 !important;
        }

        .yangshi-list-card-body a:hover {
            background: #f0f4f8 !important;
        }

        .yangshi-list-card-body a.yangshi-active {
            background: #ffebee !important; /* 适配红色主调 */
            color: #e53935 !important;
            border-left: 4px solid #e53935 !important;
            padding-left: 6px !important;
            font-weight: 600 !important;
        }

        html, body {
            margin: 0 !important;
            padding: 0 !important;
            overflow: hidden !important;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        }

        /* 禁用原页面滚动 */
        .yangshi-clean-mode {
            overflow: hidden !important;
        }
    `);

    /**
     * 查找视频核心容器(适配央视频DOM结构)
     */
    function findVideoColumn() {
        // 优先找视频元素,再向上找核心容器
        const video = document.querySelector('video');
        if (!video) return null;

        let el = video.parentElement;
        const vw = window.innerWidth, vh = window.innerHeight;

        // 向上遍历找到足够大的容器(视频核心区)
        while (el && el !== document.body) {
            const r = el.getBoundingClientRect();
            if (r.width > vw * 0.3 && r.height > vh * 0.3) return el;
            el = el.parentElement;
        }
        return video.parentElement;
    }

    /**
     * 查找视频的主容器
     */
    function findMainContainer(videoColumn) {
        if (!videoColumn) return null;
        let parent = videoColumn.parentElement;

        while (parent && parent !== document.body) {
            const kids = Array.from(parent.children).filter(c => c.offsetWidth > 0);
            if (kids.length >= 1) return parent;
            parent = parent.parentElement;
        }
        return document.body;
    }

    /**
     * 应用自定义布局
     */
    function applyLayout() {
        // 避免重复执行
        if (document.querySelector('.yangshi-clean-main')) return;

        const videoColumn = findVideoColumn();
        if (!videoColumn) return;

        const main = findMainContainer(videoColumn);
        if (!main) return;

        // 标记主容器
        main.classList.add('yangshi-clean-main');
        videoColumn.classList.add('yangshi-video-card');

        // 包装视频区域(16:9比例)
        if (!videoColumn.querySelector('.yangshi-video-wrap')) {
            const wrap = document.createElement('div');
            wrap.className = 'yangshi-video-wrap';
            while (videoColumn.firstChild) wrap.appendChild(videoColumn.firstChild);
            videoColumn.appendChild(wrap);
        }

        // 创建右侧频道列表
        const listContainer = document.createElement('div');
        listContainer.className = 'yangshi-list-container';

        const listCard = document.createElement('div');
        listCard.className = 'yangshi-list-card';
        listCard.innerHTML = `
            <div class="yangshi-list-card-header">央视频道列表</div>
            <div class="yangshi-list-card-body"></div>
        `;

        const body = listCard.querySelector('.yangshi-list-card-body');
        const curUrl = new URL(window.location.href);
        const curChannelId = curUrl.searchParams.get('channelId') || '';

        // 生成频道链接
        CHANNELS.forEach(c => {
            const a = document.createElement('a');
            a.href = 'javascript:void(0)';
            a.textContent = c.n;

            // 存储原始URL用于后续跳转
            a.dataset.url = new URL(c.u, location.origin).href;

            // 标记当前激活频道
            const linkUrl = new URL(new URL(c.u, location.origin).href);
            const linkChannelId = linkUrl.searchParams.get('channelId') || '';
            if (linkChannelId === curChannelId) {
                a.classList.add('yangshi-active');
            }

            // 添加点击事件处理
            a.addEventListener('click', function(e) {
                e.preventDefault();
                const targetUrl = this.dataset.url;

                // 显示加载状态
                this.style.backgroundColor = '#e3f2fd';

                // 延迟跳转以让用户看到反馈
                setTimeout(() => {
                    window.location.href = targetUrl;
                }, 300);
            });

            body.appendChild(a);
        });

        // 列表触发条
        const listTab = document.createElement('div');
        listTab.className = 'yangshi-list-tab';
        listTab.textContent = '央视频道列表\n双击视频全屏';

        listContainer.appendChild(listTab);
        listContainer.appendChild(listCard);
        document.body.appendChild(listContainer);

        // 添加两侧占位
        const spacerLeft = document.createElement('div');
        spacerLeft.className = 'yangshi-video-spacer';
        const spacerRight = document.createElement('div');
        spacerRight.className = 'yangshi-video-spacer';

        videoColumn.insertAdjacentElement('beforebegin', spacerLeft);
        videoColumn.insertAdjacentElement('afterend', spacerRight);

        // 隐藏主容器内非核心元素
        Array.from(main.children).forEach(child => {
            if (child !== videoColumn && child !== spacerLeft && child !== spacerRight) {
                child.style.display = 'none';
            }
        });

        // 移动主容器到body最外层
        document.body.prepend(main);
        document.body.classList.add('yangshi-clean-mode');

        // 同步列表高度与视频卡片
        const videoRect = videoColumn.getBoundingClientRect();
        listContainer.style.top = videoRect.top + 'px';
        listContainer.style.height = videoRect.height + 'px';

        // 双击视频全屏
        const videoWrap = videoColumn.querySelector('.yangshi-video-wrap');
        const fullscreenTarget = videoWrap || videoColumn;
        if (fullscreenTarget && !fullscreenTarget.dataset.fullscreenBound) {
            fullscreenTarget.dataset.fullscreenBound = '1';
            fullscreenTarget.addEventListener('dblclick', function() {
                const el = document.fullscreenElement || document.webkitFullscreenElement;
                if (el) {
                    (document.exitFullscreen || document.webkitExitFullscreen).call(document);
                } else {
                    const target = fullscreenTarget.querySelector('video') || fullscreenTarget;
                    (target.requestFullscreen || target.webkitRequestFullscreen || target.webkitRequestFullScreen).call(target);
                }
            });
        }
    }

    /**
     * 初始化脚本(适配页面加载时机)
     */
    function init() {
        // 页面加载完成后执行,增加延迟适配央视频异步加载
        const run = () => setTimeout(applyLayout, 1500);

        if (document.readyState === 'complete') {
            run();
        } else {
            window.addEventListener('load', run);
        }

        // 监听DOM变化,确保视频加载后触发布局
        const obs = new MutationObserver((mutations) => {
            if (!document.querySelector('.yangshi-clean-main') && document.querySelector('video')) {
                applyLayout();
            }
        });

        obs.observe(document.documentElement, {
            childList: true,
            subtree: true,
            attributes: true
        });
    }

    init();
})();
is.lee 发表于 2026-2-28 13:13
要是再能弄个能装在电视上面的APP就好了
无知灰灰 发表于 2026-2-22 18:45
其实装了去广告插件可以自己过滤一下就行了。。。一样效果。。
agnostic 发表于 2026-2-22 18:56
是不是就和webview电视软件一样,自动加载官方直播自动全屏
华昕 发表于 2026-2-25 11:30
本帖最后由 华昕 于 2026-2-25 14:44 编辑
nojon 发表于 2026-2-24 09:52
还是这个网址的频道最全
https://www.yangshipin.cn/tv/home

这个网址后面那些需要VIP才能看的,所有72个频道,分三栏显示,自动隐藏频道列表,但鼠标隐藏后,恢复显示鼠标图标有点问题。
试试这个代码,添加到油猴里面看看:
[JavaScript] 纯文本查看 复制代码
// // ==UserScript==
// [url=home.php?mod=space&uid=170990]@name[/url]         央视频直播纯净版 (72频道三栏完美版)
// [url=home.php?mod=space&uid=467642]@namespace[/url]    http://tampermonkey.net/
// [url=home.php?mod=space&uid=1248337]@version[/url]      1.6
// [url=home.php?mod=space&uid=686208]@AuThor[/url]       User
// [url=home.php?mod=space&uid=195849]@match[/url]        https://www.yangshipin.cn/tv/home*
// [url=home.php?mod=space&uid=609072]@grant[/url]        GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    const CHANNELS = [
        { n: 'CCTV-1 综合', id: '600001859' }, { n: 'CCTV-2 财经', id: '600001800' },
        { n: 'CCTV-3 综艺', id: '600001801' }, { n: 'CCTV-4 中文国际', id: '600001814' },
        { n: 'CCTV-5 体育', id: '600001818' }, { n: 'CCTV-5+ 体育赛事', id: '600001817' },
        { n: 'CCTV-6 电影', id: '600108442' }, { n: 'CCTV-7 国防军事', id: '600004092' },
        { n: 'CCTV-8 电视剧', id: '600001803' }, { n: 'CCTV-9 纪录', id: '600004078' },
        { n: 'CCTV-10 科教', id: '600001805' }, { n: 'CCTV-11 戏曲', id: '600001806' },
        { n: 'CCTV-12 社会与法', id: '600001807' }, { n: 'CCTV-13 新闻', id: '600001811' },
        { n: 'CCTV-14 少儿', id: '600001809' }, { n: 'CCTV-15 音乐', id: '600001815' },
        { n: 'CCTV-16 奥林匹克', id: '600098637' }, { n: 'CCTV-16 4k', id: '600099502' },
        { n: 'CCTV-17 农业农村', id: '600001810' }, { n: 'CCTV-4K 超高清', id: '600002264' },
        { n: 'CCTV-8K 超高清', id: '600156816' }, { n: 'CGTN', id: '600014550' },
        { n: 'CGTN法语', id: '600084704' }, { n: 'CGTN俄语', id: '600084758' },
        { n: 'CGTN阿拉伯语', id: '600084782' }, { n: 'CGTN西班牙语', id: '600084744' },
        { n: 'CGTN外语纪录', id: '600084781' }, { n: 'CCTV-风云剧场', id: '600099658' },
        { n: 'CCTV-第一剧场', id: '600099655' }, { n: 'CCTV-怀旧剧场', id: '600099620' },
        { n: 'CCTV-世界地理', id: '600099637' }, { n: 'CCTV-风云音乐', id: '600099660' },
        { n: 'CCTV-兵器科技', id: '600099649' }, { n: 'CCTV-风云足球', id: '600099636' },
        { n: 'CCTV-高尔夫', id: '600099659' }, { n: 'CCTV-女性时尚', id: '600099650' },
        { n: 'CCTV-文化精品', id: '600099653' }, { n: 'CCTV-台球', id: '600099652' },
        { n: 'CCTV-电视指南', id: '600099656' }, { n: 'CCTV-卫生健康', id: '600099651' },
        { n: '北京卫视', id: '600002309' }, { n: '江苏卫视', id: '600002521' },
        { n: '东方卫视', id: '600002483' }, { n: '浙江卫视', id: '600002520' },
        { n: '湖南卫视', id: '600002475' }, { n: '湖北卫视', id: '600002508' },
        { n: '广东卫视', id: '600002485' }, { n: '广西卫视', id: '600002509' },
        { n: '黑龙江卫视', id: '600002498' }, { n: '海南卫视', id: '600002506' },
        { n: '重庆卫视', id: '600002531' }, { n: '深圳卫视', id: '600002481' },
        { n: '四川卫视', id: '600002516' }, { n: '河南卫视', id: '600002525' },
        { n: '福建东南', id: '600002484' }, { n: '贵州卫视', id: '600002490' },
        { n: '江西卫视', id: '600002503' }, { n: '辽宁卫视', id: '600002505' },
        { n: '安徽卫视', id: '600002532' }, { n: '河北卫视', id: '600002493' },
        { n: '山东卫视', id: '600002513' }, { n: '天津卫视', id: '600152137' },
        { n: '吉林卫视', id: '600190405' }, { n: '陕西卫视', id: '600190400' },
        { n: '宁夏卫视', id: '600190737' }, { n: '内蒙古', id: '600190401' },
        { n: '云南卫视', id: '600190402' }, { n: '山西卫视', id: '600190407' },
        { n: '青海卫视', id: '600190406' }, { n: '西藏卫视', id: '600190403' },
        { n: '中国教育1', id: '600171827' }, { n: '新疆卫视', id: '600152138' }
    ];

    GM_addStyle(`
        body, html { background: #000 !important; overflow: hidden !important; margin: 0 !important; }
        video, .video-player-container, #player-container {
            position: fixed !important; top: 0 !important; left: 0 !important;
            width: 100vw !important; height: 100vh !important;
            z-index: 999998 !important; background: #000 !important;
        }
        .header-wrap, .side-bar, .download-app, .footer-wrap, .right-section, 
        [class*="Guide"], [class*="Header"], [class*="Footer"] { display: none !important; }
        
        #custom-ysp-panel {
            position: fixed !important; right: -480px; top: 50%;
            transform: translateY(-50%); background: rgba(255, 255, 255, 0.98) !important;
            border-radius: 15px 0 0 15px !important; box-shadow: -15px 0 35px rgba(0,0,0,0.8);
            z-index: 2147483647 !important; transition: right 0.4s ease;
            padding: 12px; display: grid !important;
            grid-template-columns: repeat(3, 145px); gap: 2px 8px;
            max-height: 98vh; pointer-events: auto !important;
        }
        #custom-ysp-panel.show { right: 0 !important; }
        .list-item {
            display: block !important; padding: 3px 6px !important; color: #333 !important;
            text-decoration: none !important; font-size: 11px !important;
            border-radius: 4px !important; white-space: nowrap; cursor: pointer !important;
        }
        .list-item:hover { background: #f2f2f2; color: #ff0000 !important; }
        .list-item.active { background: #ff0000 !important; color: #fff !important; font-weight: bold; }
        html.force-hide-cursor, html.force-hide-cursor * { cursor: none !important; }
    `);

    let cursorTimer = null;
    let isPanelShown = false;

    function setCursor(visible) {
        document.documentElement.classList.toggle('force-hide-cursor', !visible);
    }

    function resetTimer() {
        setCursor(true);
        if (cursorTimer) clearTimeout(cursorTimer);
        cursorTimer = setTimeout(() => { if (!isPanelShown) setCursor(false); }, 3000);
    }

    function init() {
        if (document.getElementById('custom-ysp-panel')) return;
        const panel = document.createElement('div');
        panel.id = 'custom-ysp-panel';
        CHANNELS.forEach(c => {
            const el = document.createElement('div');
            el.className = 'list-item';
            el.textContent = c.n;
            el.onclick = (e) => { e.stopPropagation(); window.location.href = `https://www.yangshipin.cn/tv/home?pid=${c.id}`; };
            if (window.location.search.includes(c.id)) el.classList.add('active');
            panel.appendChild(el);
        });
        document.body.appendChild(panel);

        window.addEventListener('mousemove', (e) => {
            resetTimer();
            const w = window.innerWidth;
            if (e.clientX > w - 40) { panel.classList.add('show'); isPanelShown = true; setCursor(true); }
            else if (e.clientX < w - 460) { panel.classList.remove('show'); isPanelShown = false; }
        }, { capture: true });
    }

    init();
    resetTimer();
    setInterval(() => {
        init();
        const v = document.querySelector('video');
        if (v) v.style.setProperty('z-index', '999998', 'important');
        document.querySelectorAll('[class*="Close"], .close-icon').forEach(x => x.click());
    }, 1000);})();
huangmin1111 发表于 2026-2-28 14:44
本帖最后由 huangmin1111 于 2026-2-28 15:01 编辑

我也修改了下。请测试。
[JavaScript] 纯文本查看 复制代码
// ==UserScript==
// @name          CCTV、央视频节目过滤脚本 (修改版 - 保留控制栏)
// @namespace     http://tampermonkey.net/
// @version       2.3
// @description   过滤CCTV/央视频网页,只显示视频 + 右侧可滑出节目列表。央视频页面保留原生播放器控制栏。
// @author        作者:52PJ网Liuyang207 (修改版)
// @match         https://tv.cctv.com/live/*
// @match         https://www.yangshipin.cn/tv/*
// @grant         GM_addStyle
// ==/UserScript==

(function() {
    'use strict';

    // ==================== 频道配置数据 (完全保留) ====================
    const CCTV_CHANNELS = [
        { n: 'CCTV-1 综合', u: '/live/cctv1/' },
        { n: 'CCTV-2 财经', u: '/live/cctv2/' },
        { n: 'CCTV-3 综艺', u: '/live/cctv3/' },
        { n: 'CCTV-4 中文国际', u: '/live/cctv4/' },
        { n: 'CCTV-5 体育', u: '/live/cctv5/' },
        { n: 'CCTV-5+ 体育赛事', u: '/live/cctv5plus/' },
        { n: 'CCTV-6 电影', u: '/live/cctv6/' },
        { n: 'CCTV-7 国防军事', u: '/live/cctv7/' },
        { n: 'CCTV-8 电视剧', u: '/live/cctv8/' },
        { n: 'CCTV-9 纪录', u: '/live/cctvjilu/' },
        { n: 'CCTV-10 科教', u: '/live/cctv10/' },
        { n: 'CCTV-11 戏曲', u: '/live/cctv11/' },
        { n: 'CCTV-12 社会与法', u: '/live/cctv12/' },
        { n: 'CCTV-13 新闻', u: '/live/cctv13/' },
        { n: 'CCTV-14 少儿', u: '/live/cctvchild/' },
        { n: 'CCTV-15 音乐', u: '/live/cctv15/' },
        { n: 'CCTV-16 奥林匹克', u: '/live/cctv16/' },
        { n: 'CCTV-17 农业农村', u: '/live/cctv17/' }
    ];

    const YANG_CHANNELS = [
        // 央视频道 (CCTV)
        { n: '--- 央视频道 ---', pid: null },
        { n: 'CCTV-1 综合', pid: '600001859' },
        { n: 'CCTV-2 财经', pid: '600001800' },
        { n: 'CCTV-3 综艺', pid: '600001801' },
        { n: 'CCTV-4 中文国际', pid: '600001814' },
        { n: 'CCTV-5 体育', pid: '600001818' },
        { n: 'CCTV-5+ 体育赛事', pid: '600001817' },
        { n: 'CCTV-6 电影', pid: '600108442' },
        { n: 'CCTV-7 国防军事', pid: '600004092' },
        { n: 'CCTV-8 电视剧', pid: '600001803' },
        { n: 'CCTV-9 纪录', pid: '600004078' },
        { n: 'CCTV-10 科教', pid: '600001805' },
        { n: 'CCTV-11 戏曲', pid: '600001806' },
        { n: 'CCTV-12 社会与法', pid: '600001807' },
        { n: 'CCTV-13 新闻', pid: '600001811' },
        { n: 'CCTV-14 少儿', pid: '600001809' },
        { n: 'CCTV-15 音乐', pid: '600001815' },
        { n: 'CCTV-16 奥林匹克', pid: '600098637' },
        { n: 'CCTV-16 4K', pid: '600099502' },
        { n: 'CCTV-17 农业农村', pid: '600001810' },
        { n: 'CCTV-4K 超高清', pid: '600002264' },
        { n: 'CCTV-8K 超高清', pid: '600156816' },
        { n: 'CGTN', pid: '600014550' }, // 推测
        { n: 'CGTN 法语频道', pid: '600084704' }, // 推测
        { n: 'CGTN 俄语频道', pid: '600084758' }, // 推测 (对应 CCTV16-HD)
        { n: 'CGTN 阿拉伯语频道', pid: '600084782' },      // 推测
        { n: 'CGTN 西班牙语频道', pid: '600084744' }, // 推测
        { n: 'CGTN 外语纪录频道', pid: '600084781' }, // 推测
        { n: 'CCTV-风云剧场频道', pid: '600099658' }, // 推测
        { n: 'CCTV-第一剧场频道', pid: '600099655' }, // 推测
        { n: 'CCTV-怀旧剧场频道', pid: '600099620' }, // 推测
        { n: 'CETV-中国教育频道', pid: '600171827' },// 推测
        // ... 可根据需要添加更多CGTN频道

        // 卫视频道 (示例,需要补充正确的PID)
        { n: '--- 卫视频道 ---', pid: null },
        { n: '北京卫视', pid: '600002309' },
        { n: '江苏卫视', pid: '600002521' },
        { n: '东方卫视', pid: '600002483' },
        { n: '浙江卫视', pid: '600002520' },
        { n: '湖南卫视', pid: '600002475' },
        { n: '湖北卫视', pid: '600002508' },
        { n: '广东卫视', pid: '600002485' },
        { n: '广西卫视', pid: '600002509' },
        { n: '黑龙江卫视', pid: '600002498' },
        { n: '海南卫视', pid: '600002506' },
        { n: '重庆卫视', pid: '600002531' },
        { n: '深圳卫视', pid: '600002481' },
        { n: '四川卫视', pid: '600002516' },
        { n: '河南卫视', pid: '600002525' },
        { n: '东南卫视', pid: '600002484' },
        { n: '贵州卫视', pid: '600002490' },
        { n: '江西卫视', pid: '600002503' },
        { n: '辽宁卫视', pid: '600002505' },
        { n: '安徽卫视', pid: '600002532' },
        { n: '河北卫视', pid: '600002493' },
        { n: '山东卫视', pid: '600002513' },
        { n: '天津卫视', pid: '600152137' },
        { n: '吉林卫视', pid: '600190405' },
        { n: '陕西卫视', pid: '600190400' },
        { n: '宁夏卫视', pid: '600190737' },
        { n: '内蒙古卫视', pid: '600190401' },
        { n: '云南卫视', pid: '600190402' },
        { n: '山西卫视', pid: '600190407' },
        { n: '青海卫视', pid: '600190406' },
        { n: '西藏卫视', pid: '600190403' },
        { n: '新疆卫视', pid: '600152138' }
    ];

    // ==================== 样式注入 (完全保留,仅添加必要的微调) ====================
   GM_addStyle(`
        body.cctv-clean-mode > *:not(.cctv-clean-main):not(.cctv-list-container) {
            display: none !important;
        }

        .cctv-clean-main {
            display: flex !important;
            flex-direction: row !important;
            align-items: stretch !important;
            gap: 30px !important;
            width: 100% !important;
            height: 100vh !important;
            padding: 25px !important;
            box-sizing: border-box !important;
            background: linear-gradient(145deg, #b8c2cc 0%, #9ca8b5 50%, #8a96a4 100%) !important;
        }

        .cctv-video-card {
            flex: 3 1 auto !important;
            background: #000 !important;
            border-radius: 20px !important;
            box-shadow: 0 25px 50px rgba(0,0,0,0.3) !important;
            overflow: hidden !important;
            display: flex !important;
            align-items: stretch !important;
            justify-content: center !important;
            border: 1px solid rgba(255,255,255,0.1) !important;
            min-width: 0 !important;
            max-width: 70vw !important;
        }

        body:not(.yangshipin-layout) .cctv-video-card {
            height: 100% !important;
        }

        .yangshipin-layout .cctv-clean-main {
            padding: 20px 40px !important;
            gap: 30px !important;
        }

        .yangshipin-layout .cctv-video-spacer {
            flex: 1.2 !important;
            min-width: 40px !important;
        }

        .yangshipin-layout .cctv-video-card {
            flex: 3 1 auto !important;
            max-width: 70vw !important;
            width: auto !important;
            min-width: 0 !important;
            margin: 0 auto !important;
            height: auto !important;
            aspect-ratio: 16/9 !important;
        }

        .cctv-video-spacer {
            flex: 1 !important;
            min-width: 0 !important;
        }

        .cctv-video-wrap {
            width: 100% !important;
            height: 100% !important;
            display: flex !important;
            align-items: stretch !important;
            justify-content: center !important;
            background: #000 !important;
            overflow: hidden !important;
        }

        .cctv-video-wrap video,
        .cctv-video-wrap canvas,
        .cctv-video-wrap iframe {
            width: 100% !important;
            height: 100% !important;
            object-fit: contain !important;
        }

        .cctv-video-wrap > div,
        .cctv-video-wrap > * {
            width: 100% !important;
            height: 100% !important;
        }

        .cctv-list-container {
            position: fixed !important;
            right: -170px !important;
            z-index: 999999 !important;
            display: flex !important;
            flex-direction: row !important;
            transition: right 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) !important;
        }

        .cctv-list-container:hover {
            right: 0 !important;
        }

        .cctv-list-card {
            width: 170px !important;
            height: 100% !important;
            background: rgba(255,255,255,0.12) !important;
            backdrop-filter: blur(20px) saturate(180%) !important;
            -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
            border-radius: 0 20px 20px 0 !important;
            box-shadow: -4px 0 24px rgba(0,0,0,0.3), inset 1px 0 0 rgba(255,255,255,0.2) !important;
            overflow: hidden !important;
            display: flex !important;
            flex-direction: column !important;
            border: 1px solid rgba(255,255,255,0.18) !important;
            border-left: none !important;
        }

        .cctv-list-tab {
            width: 40px !important;
            background: linear-gradient(180deg, rgba(0,212,255,0.9) 0%, rgba(0,150,199,0.95) 50%, #0066aa 100%) !important;
            color: #fff !important;
            font-size: 14px !important;
            font-weight: 700 !important;
            writing-mode: vertical-rl !important;
            letter-spacing: 4px !important;
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            cursor: pointer !important;
            border-radius: 10px 0 0 10px !important;
            box-shadow: -4px 0 20px rgba(0,212,255,0.3), inset 0 1px 0 rgba(255,255,255,0.3) !important;
            flex-shrink: 0 !important;
            border: 1px solid rgba(255,255,255,0.25) !important;
            border-right: none !important;
            height: 100% !important;
        }

        .cctv-list-card-header {
            padding: 10px 14px !important;
            font-size: 14px !important;
            font-weight: 600 !important;
            color: rgba(255,255,255,0.95) !important;
            border-bottom: 1px solid rgba(255,255,255,0.15) !important;
            background: rgba(255,255,255,0.08) !important;
            flex-shrink: 0 !important;
            text-align: center !important;
            text-shadow: 0 1px 2px rgba(0,0,0,0.3) !important;
        }

        .cctv-platform-switch {
            display: flex !important;
            align-items: center !important;
            justify-content: center !important;
            gap: 8px !important;
            padding: 8px 14px !important;
            border-bottom: 1px solid rgba(255,255,255,0.12) !important;
            background: rgba(0,0,0,0.15) !important;
        }

        .cctv-platform-switch-btn {
            flex: 1 !important;
            padding: 6px 8px !important;
            border: 1px solid rgba(255,255,255,0.2) !important;
            border-radius: 6px !important;
            background: rgba(255,255,255,0.08) !important;
            color: rgba(255,255,255,0.85) !important;
            font-size: 12px !important;
            font-weight: 500 !important;
            text-decoration: none !important;
            text-align: center !important;
            cursor: pointer !important;
            transition: all 0.2s ease !important;
            position: relative !important;
            overflow: hidden !important;
        }

        .cctv-platform-switch-btn::before {
            content: '' !important;
            position: absolute !important;
            inset: 0 !important;
            background: linear-gradient(135deg, rgba(0,212,255,0.15) 0%, transparent 50%, rgba(0,212,255,0.08) 100%) !important;
            opacity: 0 !important;
            transition: opacity 0.2s ease !important;
        }

        .cctv-platform-switch-btn:hover {
            background: rgba(255,255,255,0.15) !important;
            border-color: rgba(0,212,255,0.5) !important;
            color: #00d4ff !important;
            transform: translateY(-1px) !important;
            box-shadow: 0 2px 8px rgba(0,212,255,0.2) !important;
        }

        .cctv-platform-switch-btn:hover::before {
            opacity: 1 !important;
        }

        .cctv-platform-switch-btn:active {
            transform: translateY(0) scale(0.98) !important;
        }

        .cctv-list-card-body {
            flex: 1 !important;
            overflow-y: auto !important;
            scrollbar-width: none !important;
            padding: 4px 8px !important;
        }
        .cctv-list-card-body::-webkit-scrollbar {
            display: none !important;
        }

        .cctv-list-card-body a {
            display: block !important;
            padding: 3px 8px !important;
            margin: 0 !important;
            border-radius: 8px !important;
            color: rgba(255,255,255,0.9) !important;
            text-decoration: none !important;
            font-size: 13px !important;
            line-height: 1.2 !important;
        }

        .cctv-list-card-body a:hover {
            background: rgba(255,255,255,0.15) !important;
        }

        .cctv-list-card-body a.cctv-active {
            background: rgba(0,212,255,0.25) !important;
            color: #00d4ff !important;
            border-left: 3px solid #00d4ff !important;
            padding-left: 5px !important;
            font-weight: 600 !important;
        }

        html, body {
            margin: 0 !important;
            padding: 0 !important;
            width: 100% !important;
            height: 100% !important;
            overflow: hidden !important;
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
        }

        /* 确保央视频区域鼠标指针可见 */
        .yangshipin-layout .cctv-video-card,
        .yangshipin-layout .cctv-video-wrap,
        .yangshipin-layout .cctv-video-wrap video {
            cursor: default !important;
        }

        /* 鼠标悬停时显示指针手型 */
        .yangshipin-layout .cctv-video-card:hover,
        .yangshipin-layout .cctv-video-wrap:hover {
            cursor: pointer !important;
        }
    `);

    // ==================== 工具函数 ====================
    function getCurrentPlatform() {
        const host = location.hostname.toLowerCase();
        if (host.includes('tv.cctv.com')) return 'cctv';
        if (host.includes('yangshipin.cn')) return 'yangshipin';
        return null;
    }

    // ────────────────────────────── CCTV 专用 (完全保留) ──────────────────────────────
    function findCCTVVideoColumn() {
        const video = document.querySelector('video');
        if (!video) return null;
        let el = video.parentElement;
        const vw = window.innerWidth;
        const vh = window.innerHeight;
        let count = 0;
        while (el && el !== document.body && count < 10) {
            const rect = el.getBoundingClientRect();
            if (rect.width > vw * 0.35 && rect.height > vh * 0.35) {
                return el;
            }
            el = el.parentElement;
            count++;
        }
        return video.parentElement || null;
    }

    function applyCCTVLayout() {
        if (document.querySelector('.cctv-clean-main')) return;
        const videoColumn = findCCTVVideoColumn();
        if (!videoColumn) return;
        let mainContainer = videoColumn.parentElement;
        while (mainContainer && mainContainer !== document.body) {
            const children = Array.from(mainContainer.children).filter(c => c.offsetWidth > 0);
            if (children.length >= 2) break;
            mainContainer = mainContainer.parentElement;
        }
        if (!mainContainer || mainContainer === document.body) mainContainer = document.body;
        mainContainer.classList.add('cctv-clean-main');
        videoColumn.classList.add('cctv-video-card');

        const listContainer = document.createElement('div');
        listContainer.className = 'cctv-list-container';
        const listTab = document.createElement('div');
        listTab.className = 'cctv-list-tab';
        listTab.textContent = 'CCTV频道列表      双击视频全屏';
        const listCard = document.createElement('div');
        listCard.className = 'cctv-list-card';
        listCard.innerHTML = '<div class="cctv-list-card-header">频道列表</div><div class="cctv-platform-switch"><a href="https://www.yangshipin.cn/tv/" class="cctv-platform-switch-btn">跳转央视频</a></div><div class="cctv-list-card-body"></div>';
        const body = listCard.querySelector('.cctv-list-card-body');
        const curPath = location.pathname.replace(/\/$/, '').toLowerCase();
        CCTV_CHANNELS.forEach(channel => {
            const a = document.createElement('a');
            a.href = new URL(channel.u, location.origin).href;
            a.textContent = channel.n;
            const linkPath = new URL(a.href).pathname.replace(/\/$/, '').toLowerCase();
            if (curPath === linkPath || curPath.startsWith(linkPath + '/')) {
                a.classList.add('cctv-active');
            }
            body.appendChild(a);
        });
        listContainer.appendChild(listTab);
        listContainer.appendChild(listCard);
        document.body.appendChild(listContainer);

        const spacerLeft = document.createElement('div');
        spacerLeft.className = 'cctv-video-spacer';
        const spacerRight = document.createElement('div');
        spacerRight.className = 'cctv-video-spacer';
        videoColumn.before(spacerLeft);
        videoColumn.after(spacerRight);
        Array.from(mainContainer.children).forEach(child => {
            if (![spacerLeft, videoColumn, spacerRight].includes(child)) {
                child.style.display = 'none';
            }
        });
        document.body.prepend(mainContainer);
        document.body.classList.add('cctv-clean-mode');

        const videoWrap = videoColumn;
        if (videoWrap) {
            videoWrap.addEventListener('dblclick', () => {
                const video = videoWrap.querySelector('video');
                if (video) {
                    if (document.fullscreenElement) {
                        document.exitFullscreen();
                    } else {
                        videoWrap.requestFullscreen();
                    }
                }
            });
        }

        const syncList = () => {
            const card = document.querySelector('.cctv-video-card');
            const list = document.querySelector('.cctv-list-container');
            if (card && list) {
                const rect = card.getBoundingClientRect();
                list.style.top = rect.top + 'px';
                list.style.height = rect.height + 'px';
            }
        };
        syncList();
        window.addEventListener('resize', syncList);
    }

    // ========== 央视频 专用 (修改核心:恢复原控制台) ==========
    function findYangPlayerContainer() {
        // 参考原脚本 findPlayerContainer 的逻辑:优先找 video 标签的容器
        const video = document.querySelector('video');
        if (!video) return null;

        // 尝试直接找到包含 video 的合适容器 (参考原脚本思路)
        let container = video.closest('div[class*="container"], div[class*="wrapper"], section, div[class*="player"], div[class*="Player"], #player');

        if (!container) {
            // 如果没有找到特定容器,使用 video 的父元素 (原脚本的备选方案)
            container = video.parentElement;
        }

        // 确保容器不为 body 本身,避免范围过大
        if (container === document.body) {
            container = video.parentElement;
        }

        return container;
    }

    function applyYangLayout() {
        if (document.querySelector('.cctv-clean-main')) return;
        document.body.classList.add('yangshipin-layout');

        // 1. 查找播放器容器 (采用类似原脚本的简单逻辑)
        const playerContainer = findYangPlayerContainer();
        if (!playerContainer) {
            console.log('未找到播放器容器');
            return;
        }
        console.log('央视频播放器容器:', playerContainer);

        // 2. 标记播放器容器,但**不进行深度包装或移动其内部元素**
        playerContainer.classList.add('cctv-video-card');

        // 3. 创建主布局容器,并将播放器容器移动到其中 (这是必要的布局调整)
        const mainLayout = document.createElement('div');
        mainLayout.className = 'cctv-clean-main';

        const spacerLeft = document.createElement('div');
        spacerLeft.className = 'cctv-video-spacer';
        const spacerRight = document.createElement('div');
        spacerRight.className = 'cctv-video-spacer';

        // 将播放器容器移动到主布局中间 (这一步会改变其父元素,但不会破坏其内部结构)
        mainLayout.appendChild(spacerLeft);
        mainLayout.appendChild(playerContainer);
        mainLayout.appendChild(spacerRight);

        document.body.prepend(mainLayout);
        document.body.classList.add('cctv-clean-mode');

        // 4. 隐藏其他页面元素,但确保播放器容器内的任何元素都不被隐藏
        const selectorsToHide = [
            'header', 'footer', 'nav', 'aside',
            '.header', '.footer', '.nav', '.sidebar',
            '[class*="guide"]', '[class*="Guide"]',
            '[class*="navbar"]', '[class*="Navbar"]',
            '.channel-list', '.right-side', '.recommend',
            '.top-bar', '.bottom-bar', '.menu'
        ];

        selectorsToHide.forEach(selector => {
            document.querySelectorAll(selector).forEach(el => {
                // 关键:不隐藏播放器容器本身及其内部的任何元素
                if (!playerContainer.contains(el) && el !== playerContainer) {
                    el.style.display = 'none';
                }
            });
        });

        // 5. 构建右侧频道列表 (样式和长度完全保留)
        const listContainer = document.createElement('div');
        listContainer.className = 'cctv-list-container';

        const listTab = document.createElement('div');
        listTab.className = 'cctv-list-tab';
        listTab.textContent = '央视频频道      双击视频全屏';

        const listCard = document.createElement('div');
        listCard.className = 'cctv-list-card';
        listCard.innerHTML = '<div class="cctv-list-card-header">央视频频道</div><div class="cctv-platform-switch"><a href="https://tv.cctv.com/live/" class="cctv-platform-switch-btn">跳转CCTV</a></div><div class="cctv-list-card-body"></div>';

        const body = listCard.querySelector('.cctv-list-card-body');
        const currentUrl = location.href.toLowerCase();

        YANG_CHANNELS.forEach(item => {
            if (item.pid === null) {
                const divider = document.createElement('div');
                divider.className = 'cctv-list-divider';
                divider.textContent = item.n;
                body.appendChild(divider);
            } else {
                const a = document.createElement('a');
                a.href = '/tv/home?pid=' + item.pid;
                a.textContent = item.n;
                a.target = '_top';
                if (currentUrl.includes('pid=' + item.pid)) {
                    a.classList.add('cctv-active');
                }
                body.appendChild(a);
            }
        });

        listContainer.appendChild(listTab);
        listContainer.appendChild(listCard);
        document.body.appendChild(listContainer);

        // 6. 添加双击全屏功能 (基于原脚本实现)
        const videoWrap = playerContainer; // 直接使用播放器容器
        if (videoWrap) {
            videoWrap.addEventListener('dblclick', function(e) {
                e.stopPropagation();
                const video = videoWrap.querySelector('video');
                if (video) {
                    if (document.fullscreenElement) {
                        document.exitFullscreen();
                    } else {
                        // 尝试让视频容器全屏,而不是 video 本身,以获得更好体验
                        videoWrap.requestFullscreen().catch(err => {
                            console.log('全屏请求失败:', err);
                        });
                    }
                }
            });
        }

        // 7. 同步列表高度
        const syncList = () => {
            const card = document.querySelector('.cctv-video-card');
            const list = document.querySelector('.cctv-list-container');
            if (card && list) {
                const rect = card.getBoundingClientRect();
                list.style.top = rect.top + 'px';
                list.style.height = rect.height + 'px';
            }
        };
        syncList();
        window.addEventListener('resize', syncList);

        console.log('央视频布局应用完成 (保留控制栏)');
    }

    // ==================== 主函数和初始化 (完全保留) ====================
    function tryApplyLayout() {
        const host = location.hostname.toLowerCase();
        if (host.includes('tv.cctv.com')) {
            applyCCTVLayout();
        } else if (host.includes('yangshipin.cn')) {
            applyYangLayout();
        }
    }

    if (document.readyState === 'complete') {
        setTimeout(tryApplyLayout, 1800);
    } else {
        window.addEventListener('load', () => {
            setTimeout(tryApplyLayout, 1800);
        });
    }

    const observer = new MutationObserver(() => {
        if (!document.querySelector('.cctv-clean-main') && document.querySelector('video')) {
            tryApplyLayout();
        }
    });
    observer.observe(document.documentElement, { childList: true, subtree: true });

})();

 楼主| liuyang207 发表于 2026-2-22 20:10
agnostic 发表于 2026-2-22 18:56
是不是就和webview电视软件一样,自动加载官方直播自动全屏

是的,大概是这个意思。
catvmis 发表于 2026-2-22 19:04
确实挺好用的。谢谢!
Tanhua238959150 发表于 2026-2-22 19:16
这是获取源视频么?
picoyiyi 发表于 2026-2-22 19:21
没想到央视的还插广告
wu1357924680 发表于 2026-2-22 20:00
现在央视也插入广告吗?
木头人_01 发表于 2026-2-22 20:01
现在央视也有广告吗
 楼主| liuyang207 发表于 2026-2-22 20:11
Tanhua238959150 发表于 2026-2-22 19:16
这是获取源视频么?

不不不,原网页浏览,只是屏蔽多余的页面内容。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-4-17 17:46

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表