CC163FullScreen

CC直播网页全屏,去掉播放器野外的元素

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         CC163FullScreen
// @namespace    https://greasyfork.org/zh-CN/users/135090
// @version      1.5.8
// @description  CC直播网页全屏,去掉播放器野外的元素
// @author       You
// @match        https://cc.163.com/1*
// @match        https://cc.163.com/2*
// @match        https://cc.163.com/3*
// @match        https://cc.163.com/4*
// @match        https://cc.163.com/5*
// @match        https://cc.163.com/6*
// @match        https://cc.163.com/7*
// @match        https://cc.163.com/8*
// @match        https://cc.163.com/9*
// @match        https://cc.163.com/live/channel/*
// @run-at       document-end
// ==/UserScript==

/* global __NEXT_DATA__, Player, HlsPlayer */
'use strict';
setTimeout(function() {
    if (location.pathname.includes("channel")) {
        const loadCSS = (href) => {
            if (!document.querySelector(`link[href="${href}"]`)) {
                const link = document.createElement('link');
                link.rel = 'stylesheet';
                link.href = href;
                document.head.appendChild(link);
            }
        };
        
        // 加载CSS样式
        loadCSS('https://cdn.jsdelivr.net/npm/xgplayer@latest/dist/index.min.css');
        // 动态加载XGPlayer
        const scripts = [
            'https://cdn.jsdelivr.net/npm/xgplayer@latest/dist/index.min.js',
            'https://cdn.jsdelivr.net/npm/xgplayer-hls@latest/dist/index.min.js'
        ];
        
        scripts.forEach(src => {
            if (!document.querySelector(`script[src="${src}"]`)) {
                const script = document.createElement('script');
                script.src = src;
                script.async = false;
                document.body.appendChild(script);
            }
        });
        const rdata = JSON.parse(document.body.querySelector("pre").textContent);
        let data = rdata?.data[0];
        // 获取直播数据{
        if (data?.is_audiolive === 1) {
                document.body.innerHTML = "<h1>音频直播,暂不支持</h1>";
                return;
        }
        setTimeout(() => initPlayer(data), 500);
        

        function initPlayer(data) {
            document.body.replaceChildren();
            document.body.style.background="#EAEAEA";
            document.title = data.nickname;
            
            // 创建播放器容器
            const container = document.createElement('div');
            container.id = 'box';
            container.style.cssText = "margin: 0 auto;;height:auto;width:88vw;background:#AAA;";
            const xgp = document.createElement('div');
            xgp.id = 'xgplayer';
            container.appendChild(xgp);
            // 创建直播间信息
            const info = document.createElement('div');
            info.style.cssText = `
                position: absolute;
                bottom: 10px;
                left: 10px;
                color: white;
                background: rgba(0,0,0,0.5);
                padding: 0;
                z-index: 999;
                border-radius: 4px;
                font-size: 16px;
            `;
            info.innerHTML = `
                <a href="https://cc.163.com/${data.ccid}" 
                   style="color:#fff;text-decoration:none">
                    ${data.nickname} 的直播间
                </a>
            `;
            container.appendChild(info);
            document.body.appendChild(container);

            // 初始化XGPlayer
            new Player({
                id: 'xgplayer',
                url: data.sharefile,
                poster: data.cover,
                isLive: true,
                autoplay: true,
                fluid: true,
                volume: 1.0,
                lang: 'zh-cn',
                cssFullscreen: true,
                plugins: [HlsPlayer]
            });
        }
    } else {
        const livedata=__NEXT_DATA__?.props?.pageProps?.roomInfoInitData?.live;
        const cid= livedata?.cid || livedata?.subcid;
        location.href = "https://cc.163.com/live/channel/?channelids=" + cid;
    }
},500);