CC163FullScreen

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

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