CC163FullScreen

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);