// ==UserScript== // @name kimi免费H5 PC 样式优化(视频强制全宽 v3) // @namespace https://greasyfork.org/users/1365074-peidu // @version 1.3.0 // @description 强制小鹅通 H5 直播视频占满浏览器宽度,高度按16:9等比例。基于 Eddie7x 的脚本由 AI 辅助修改适配,自己不懂这些。2026年4月底视频有效 // @author peidu // @license MIT // @copyright 2026, peidu; 基于 Eddie7x 的工作 (https://greasyfork.org/zh-CN/scripts/560386) // @match *://*.h5.xiaoeknow.com/* // @match *://*.h5.xet.citv.cn/* // @run-at document-end // @grant none // @downloadURL https://update.greasyfork.icu/scripts/576382/kimi%E5%85%8D%E8%B4%B9H5%20PC%20%E6%A0%B7%E5%BC%8F%E4%BC%98%E5%8C%96%EF%BC%88%E8%A7%86%E9%A2%91%E5%BC%BA%E5%88%B6%E5%85%A8%E5%AE%BD%20v3%EF%BC%89.user.js // @updateURL https://update.greasyfork.icu/scripts/576382/kimi%E5%85%8D%E8%B4%B9H5%20PC%20%E6%A0%B7%E5%BC%8F%E4%BC%98%E5%8C%96%EF%BC%88%E8%A7%86%E9%A2%91%E5%BC%BA%E5%88%B6%E5%85%A8%E5%AE%BD%20v3%EF%BC%89.meta.js // ==/UserScript== /** * 本脚本基于 Eddie7x 的 "XET H5 PC 样式优化" 修改 * 原脚本地址: https://greasyfork.org/zh-CN/scripts/560386-xet-h5-pc-%E6%A0%B7%E5%BC%8F%E4%BC%98%E5%8C%96/code * 原作者: Eddie7x * 修改日期: 2026-04-27 * 修改内容: AI 辅助适配 2026年4月小鹅通新版播放器结构 * * 原脚本采用 MIT 许可证发布 */ (function () { 'use strict'; const RATIO = 16 / 9; // 横屏直播用 16:9,竖屏改成 9/16 function injectStyle(css) { const s = document.createElement('style'); s.textContent = css; document.head.appendChild(s); } function setFullWidth(el) { el.style.setProperty('width', '100vw', 'important'); el.style.setProperty('max-width', '100vw', 'important'); el.style.setProperty('min-width', '100vw', 'important'); } function setHeightByRatio(el) { const vw = window.innerWidth; const targetHeight = Math.round(vw / RATIO); el.style.setProperty('height', targetHeight + 'px', 'important'); el.style.setProperty('max-height', targetHeight + 'px', 'important'); el.style.setProperty('min-height', targetHeight + 'px', 'important'); } function forceVideoFullWidth() { const vw = window.innerWidth; const targetHeight = Math.round(vw / RATIO); // 1. 处理 video 和 canvas document.querySelectorAll('video, canvas').forEach(el => { setFullWidth(el); setHeightByRatio(el); el.style.setProperty('object-fit', 'contain', 'important'); el.style.setProperty('display', 'block', 'important'); // 移除可能干扰的内联 height/width 属性 el.removeAttribute('height'); el.removeAttribute('width'); // 向上遍历父容器 let parent = el.parentElement; let depth = 0; while (parent && parent !== document.body && depth < 12) { const computed = window.getComputedStyle(parent); if (computed.maxWidth && computed.maxWidth !== 'none') { parent.style.setProperty('max-width', 'none', 'important'); } // 如果父容器高度被写死了,且比目标高度小,强制放大 const h = parseFloat(computed.height); if (!isNaN(h) && h > 0 && h < targetHeight) { parent.style.setProperty('height', targetHeight + 'px', 'important'); parent.style.setProperty('max-height', 'none', 'important'); } parent.style.setProperty('width', '100%', 'important'); parent.style.setProperty('margin-left', '0', 'important'); parent.style.setProperty('margin-right', '0', 'important'); parent.style.setProperty('padding-left', '0', 'important'); parent.style.setProperty('padding-right', '0', 'important'); parent.style.setProperty('box-sizing', 'border-box', 'important'); parent = parent.parentElement; depth++; } }); // 2. 处理 iframe 播放器 document.querySelectorAll('iframe').forEach(iframe => { const cls = iframe.className || ''; const src = iframe.src || ''; if ( src.includes('player') || src.includes('alive') || cls.includes('player') || cls.includes('video') || cls.includes('alive') ) { setFullWidth(iframe); setHeightByRatio(iframe); iframe.style.setProperty('border', 'none', 'important'); } }); // 3. 处理常见的小鹅通视频容器类名 const containerSelectors = [ '.alive-player-wrapper', '.alive-player-container', '.course-video-container', '.video-player-wrapper', '.player-wrapper', '.alive-wrapper .alive-content', '#app .video-container', '.alive-page-wrapper .alive-player', '.alive-video-box', '.video-box', '.player-box' ]; containerSelectors.forEach(sel => { document.querySelectorAll(sel).forEach(el => { setFullWidth(el); setHeightByRatio(el); el.style.setProperty('overflow', 'hidden', 'important'); }); }); } // ===== 注入全局样式 ===== injectStyle(` html, body { margin: 0 !important; padding: 0 !important; overflow-x: hidden !important; min-width: 100vw !important; background: #000 !important; } #application, #app, .alive-wrapper, .alive-page-wrapper, .alive-page, .alive-container, .course-container, [class*="alive-player"], [class*="video-container"], [class*="course-video"], [class*="player-wrapper"], [class*="alive-content"], [class*="template-mounted"] { width: 100vw !important; max-width: 100vw !important; margin-left: 0 !important; margin-right: 0 !important; padding-left: 0 !important; padding-right: 0 !important; } video, canvas { width: 100vw !important; max-width: 100vw !important; min-width: 100vw !important; object-fit: contain !important; display: block !important; } iframe[src*="player"], iframe[src*="alive"], .alive-player-wrapper iframe, .video-player-wrapper iframe { width: 100vw !important; max-width: 100vw !important; border: none !important; } `); // ===== 多次执行 + 持续监听 ===== const run = () => forceVideoFullWidth(); run(); setTimeout(run, 500); setTimeout(run, 1500); setTimeout(run, 3000); const observer = new MutationObserver(run); observer.observe(document.body, { childList: true, subtree: true }); window.addEventListener('resize', run); console.log('[XET-PC-v3] 视频全宽+等比例高度脚本已注入'); })();