CC163FullScreen

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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