找回密码
 立即注册→加入我们

QQ登录

只需一步,快速开始

搜索
热搜: 下载 VB C 实现 编写
查看: 225|回复: 0

网易CC直播精简到只剩播放器的书签脚本代码

[复制链接]
5 个宅币 回复本帖可获得 1 个宅币奖励! 每人限 1 次(中奖概率 50%)
发表于 2025-12-7 09:44:41 | 显示全部楼层 |阅读模式

欢迎访问技术宅的结界,请注册或者登录吧。

您需要 登录 才可以下载或查看,没有账号?立即注册→加入我们

×
如题,直播页面元素太多,影响观看体验,直接精简到只剩播放器,也没有弹幕和公屏
  1. (function() {
  2.     'use strict';
  3.    
  4.     if (location.pathname.includes("channel")) {
  5.         // 动态加载依赖
  6.         [   'https://cdnjs.cloudflare.com/ajax/libs/dplayer/1.27.1/DPlayer.min.js',
  7.             'https://cdnjs.cloudflare.com/ajax/libs/hls.js/1.5.18/hls.min.js'
  8.         ].forEach(src => {
  9.             const script = document.createElement('script');
  10.             script.src = src;
  11.             document.body.appendChild(script);
  12.         });

  13.         // 获取直播数据并初始化播放器
  14.         fetch(location.href)
  15.             .then(r => r.json())
  16.             .then(data => data?.data[0])
  17.             .then(data => {
  18.                 if (data?.is_audiolive === 1) {
  19.                     document.body.innerHTML = "<h1>音频直播,暂不支持</h1>";
  20.                     return;
  21.                 }
  22.                
  23.                 setTimeout(() => initPlayer(data), 500);
  24.             });

  25.         function initPlayer(data) {
  26.             document.body.innerHTML = '';
  27.             document.title = data.nickname;
  28.             
  29.             const playerContainer = document.createElement('div');
  30.             playerContainer.id = 'dplayer';
  31.             playerContainer.style.cssText = 'width:64%; height:auto; margin:0 auto';
  32.             
  33.             const link = document.createElement('a');
  34.             link.href = `https://cc.163.com/${data.ccid}`;
  35.             link.textContent = `直播间${data.ccid}于${data.startat}开播`;
  36.             
  37.             document.body.append(playerContainer, link);
  38.             
  39.             new DPlayer({
  40.                 container: playerContainer,
  41.                 live: true,
  42.                 volume: 1.0,
  43.                 video: {
  44.                     url: data.sharefile,
  45.                     type: 'hls',
  46.                     pic: data.cover
  47.                 }
  48.             }).fullScreen.request('web').play();
  49.         }
  50.     } else {
  51.         // 非channel页面处理
  52.         const roomData = __NEXT_DATA__?.props?.pageProps?.roomInfoInitData?.live;
  53.         if (!roomData) return;
  54.         
  55.         if (roomData.gametype === 95599) {
  56.             alert("聊天室不支持弹出播放器播放");
  57.         } else if (roomData.status > 0) {
  58.             const cid = roomData.cid || roomData.channel_id;
  59.             cid > 0 && (location.href = `//cc.163.com/live/channel/?channelids=${cid}`);
  60.         } else {
  61.             alert("未直播");
  62.         }
  63.     }
  64. })();
复制代码
回复

使用道具 举报

本版积分规则

QQ|Archiver|小黑屋|技术宅的结界 ( 滇ICP备16008837号 )|网站地图

GMT+8, 2026-3-10 01:19 , Processed in 0.028693 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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