// ==UserScript== // @name 央视频m3u8提取器 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动提取央视网视频真实m3u8地址,支持一键复制/下载/关闭 // @author 星空 // @match *://*.cctv.com/* // @match *://*.cntv.cn/* // @grant GM_xmlhttpRequest // @grant GM_notification // @grant GM_setClipboard // @connect cctv.com // @connect cntv.cn // @run-at document-start // @downloadURL https://update.greasyfork.icu/scripts/531811/%E5%A4%AE%E8%A7%86%E9%A2%91m3u8%E6%8F%90%E5%8F%96%E5%99%A8.user.js // @updateURL https://update.greasyfork.icu/scripts/531811/%E5%A4%AE%E8%A7%86%E9%A2%91m3u8%E6%8F%90%E5%8F%96%E5%99%A8.meta.js // ==/UserScript== (function() { 'use strict'; // 拦截所有XHR请求 const originalOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function(method, url) { if (url.includes('getHttpVideoInfo.do')) { this.addEventListener('load', function() { try { const response = JSON.parse(this.responseText); handleHlsUrl(response.hls_url); } catch (e) { console.error('解析失败:', e); } }); } originalOpen.apply(this, arguments); }; // 拦截Fetch请求 const originalFetch = window.fetch; window.fetch = async function(input, init) { if (typeof input === 'string' && input.includes('getHttpVideoInfo.do')) { const response = await originalFetch(input, init); const clone = response.clone(); clone.json().then(data => handleHlsUrl(data.hls_url)); return response; } return originalFetch(input, init); }; // 处理获取到的URL function handleHlsUrl(rawUrl) { const finalUrl = rawUrl.replace(/\\\//g, '/'); if (document.getElementById('cctv-hls-panel')) return; // 创建浮动控制面板 const panel = document.createElement('div'); panel.id = 'cctv-hls-panel'; panel.style = ` position: fixed; top: 20px; right: 20px; background: #fff; padding: 15px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); z-index: 99999; border-radius: 8px; min-width: 350px; animation: slideIn 0.3s ease-out; `; // 添加CSS动画 const style = document.createElement('style'); style.textContent = ` @keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } #cctv-hls-panel:hover #countdown { display: none; } `; document.head.appendChild(style); panel.innerHTML = `