// ==UserScript== // @name (免费)20262026年山西省苏教版义务教育阶段新教材省级一键学习 // @namespace http://tampermonkey.net/ // @version 3.1 // @description 点击一次即完成学习(需先点击视频播放)| 含免责声明与反馈功能 // @author AI Helper // @match https://oywuxq.vnet.weizan.cn/live/page/* // @run-at document-start // @grant unsafeWindow // @grant GM_addStyle // @icon data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMjggMTI4IiB3aWR0aD0iMTI4IiBoZWlnaHQ9IjEyOCI+PHJlY3Qgd2lkdGg9IjEyOCIgaGVpZ2h0PSIxMjgiIHJ4PSIyOCIgZmlsbD0iIzFhMWEyZSIvPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iZyIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI0ZGRDcwMCIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI0ZGOEMwMCIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjx0ZXh0IHg9IjY0IiB5PSI4MCIgZm9udC1mYW1pbHk9Ik1pY3Jvc29mdCBZYWhlaSwgUGluZ0ZhbmcgU0MsIHNhbnMtc2VyaWYiIGZvbnQtc2l6ZT0iNTYiIGZvbnQtd2VpZ2h0PSJib2xkIiBmaWxsPSJ1cmwoI2cpIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIj7np5LlrZo8L3RleHQ+PC9zdmc+ // @license MIT // ==/UserScript== (function() { 'use strict'; // ===================== 固定配置 ===================== const CONFIG = { heartbeatUrl: '', normalEndSeconds: 1, heartbeatInterval: 1, debug: true, // 反馈邮箱(修改为你自己的邮箱) feedbackEmail: '1102620555@qq.com' }; // ===================== 状态变量 ===================== let autoDetectedUrl = null; let autoDetectedHeaders = {}; let lastReportStatus = '未上报'; let lastReportTime = ''; let lastReportStatusCode = ''; let lastReportPayload = null; let lastReportResponse = null; let lastReportError = null; let heartbeatTimer = null; let studyCompleted = false; let isProcessing = false; // ===================== 自动捕获心跳 ===================== const KEYWORDS = ['zbmonitor', 'heartbeat', 'report', 'playtime', 'utrack', 'weblog', 'vzan.com/live/', 'gif']; function isHeartbeatUrl(url) { if (!url) return false; return KEYWORDS.some(kw => url.includes(kw)); } (function() { const originalOpen = unsafeWindow.XMLHttpRequest.prototype.open; unsafeWindow.XMLHttpRequest.prototype.open = function(method, url, ...args) { if (isHeartbeatUrl(url) && !autoDetectedUrl) { autoDetectedUrl = url; console.log('[自动捕获] 心跳URL:', url); } return originalOpen.call(this, method, url, ...args); }; const originalSetRequestHeader = unsafeWindow.XMLHttpRequest.prototype.setRequestHeader; unsafeWindow.XMLHttpRequest.prototype.setRequestHeader = function(header, value) { if (autoDetectedUrl) { autoDetectedHeaders[header] = value; } return originalSetRequestHeader.call(this, header, value); }; })(); (function() { const originalFetch = unsafeWindow.fetch; unsafeWindow.fetch = function(input, init) { const url = typeof input === 'string' ? input : input.url; if (isHeartbeatUrl(url) && !autoDetectedUrl) { autoDetectedUrl = url; console.log('[自动捕获] 心跳URL (fetch):', url); if (init && init.headers) { autoDetectedHeaders = Object.assign(autoDetectedHeaders, init.headers); } } return originalFetch.call(this, input, init); }; })(); // ===================== 工具函数 ===================== function log(msg) { if (CONFIG.debug) console.log('[2026山西培训]', msg); } function getVideo() { return document.getElementById('liveVideo'); } function getPlayButton() { return document.querySelector('.play_btn'); } function getTitle() { return document.title.trim() || document.querySelector('h2.room-name')?.textContent.trim() || '未知标题'; } function formatTime(sec) { if (!sec || isNaN(sec) || !isFinite(sec)) return '--:--'; const m = Math.floor(sec / 60); const s = Math.floor(sec % 60); return `${String(m).padStart(2,'0')}:${String(s).padStart(2,'0')}`; } function updateStatus(text, color = '#ffd700') { const el = document.getElementById('statusDisplay'); if (el) { el.textContent = text; el.style.color = color; } } function updateTimeLeft(text) { const el = document.getElementById('timeLeftDisplay'); if (el) el.textContent = text; } function updateReportStatus(text, color = '#8f8') { const el = document.getElementById('reportStatus'); if (el) { el.textContent = text; el.style.color = color; } } // ===================== 获取liveId ===================== function getLiveId() { const params = new URLSearchParams(window.location.search); let id = params.get('topicId'); if (id) return id; const title = getTitle(); const match = title.match(/\d{5,}/); return match ? match[0] : '1435217338'; } // ===================== 构建上报数据 ===================== function buildPayload(video, isFinal = false) { if (!video) return null; return { liveId: getLiveId(), title: getTitle(), currentTime: video.currentTime, duration: video.duration, progress: (video.currentTime / video.duration) * 100, speed: video.playbackRate, event: isFinal ? 'study_complete' : 'heartbeat', timestamp: Date.now() }; } // ===================== 判断是否为GIF上报类型 ===================== function isGifReport(url) { if (!url) return false; return /weblog\.gif|\.gif\?|image/i.test(url); } // ===================== 发送上报 ===================== function sendHeartbeat(video, isFinal = false) { if (!video) return; const payload = buildPayload(video, isFinal); if (!payload) return; const url = CONFIG.heartbeatUrl || autoDetectedUrl; if (!url) { log('模拟心跳上报(未捕获到URL)', payload); updateReportStatus('⚠️ 无地址', '#ffa500'); lastReportStatus = '未捕获地址'; lastReportPayload = payload; return; } lastReportPayload = payload; updateReportStatus('⏳ 上报中...', '#ffd700'); if (isGifReport(url)) { const params = new URLSearchParams(payload); params.delete('md5'); params.delete('expires'); const fullUrl = url + (url.includes('?') ? '&' : '?') + params.toString(); log('GIF上报 (Image):', fullUrl); const img = new Image(); let resolved = false; img.onload = function() { if (!resolved) { resolved = true; const now = new Date().toLocaleTimeString(); lastReportTime = now; lastReportStatusCode = '200 (Image)'; lastReportResponse = 'Image loaded'; lastReportError = null; updateReportStatus(`✅ 成功 ${now}`, '#8f8'); lastReportStatus = '成功'; log('GIF上报成功 (onload)'); } }; img.onerror = function() { if (!resolved) { resolved = true; const now = new Date().toLocaleTimeString(); lastReportTime = now; lastReportStatusCode = 'sent (Image error)'; lastReportResponse = 'Image onerror - request sent'; lastReportError = null; updateReportStatus(`✅ 已发送 ${now}`, '#8f8'); lastReportStatus = '成功(推测)'; log('GIF上报完成 (onerror 触发)'); } }; img.src = fullUrl; setTimeout(() => { if (!resolved) { resolved = true; const now = new Date().toLocaleTimeString(); lastReportTime = now; lastReportStatusCode = 'sent (timeout)'; lastReportResponse = 'No event but request likely sent'; lastReportError = null; updateReportStatus(`✅ 已发送 ${now}`, '#8f8'); lastReportStatus = '成功(推测)'; log('GIF上报完成(无事件,但请求已发出)'); } }, 3000); } else { const headers = { 'Content-Type': 'application/json', ...autoDetectedHeaders }; fetch(url, { method: 'POST', headers: headers, body: JSON.stringify(payload) }) .then(res => { lastReportStatusCode = res.status; return res.text().then(text => { let json = null; try { json = JSON.parse(text); } catch(e) {} return { status: res.status, text, json }; }); }) .then(({ status, text, json }) => { const now = new Date().toLocaleTimeString(); lastReportTime = now; lastReportResponse = json || text; lastReportError = null; if (status >= 200 && status < 300) { updateReportStatus(`✅ 成功 (${status}) ${now}`, '#8f8'); lastReportStatus = '成功'; } else { updateReportStatus(`❌ 失败 (${status}) ${now}`, '#f88'); lastReportStatus = '失败'; } }) .catch(err => { const now = new Date().toLocaleTimeString(); lastReportTime = now; lastReportError = err.message; lastReportResponse = null; updateReportStatus(`❌ 网络错误 ${now}`, '#f88'); lastReportStatus = '网络错误'; }); } } // ===================== 心跳定时器 ===================== function startHeartbeat(video) { if (heartbeatTimer) clearInterval(heartbeatTimer); heartbeatTimer = setInterval(() => { if (video && !studyCompleted) { sendHeartbeat(video, false); } else { clearInterval(heartbeatTimer); heartbeatTimer = null; } }, CONFIG.heartbeatInterval * 1000); } function stopHeartbeat() { if (heartbeatTimer) { clearInterval(heartbeatTimer); heartbeatTimer = null; } } // ===================== 等待函数 ===================== function waitForVideo(timeout = 30000) { return new Promise((resolve, reject) => { const start = Date.now(); const check = () => { const video = getVideo(); if (video) { resolve(video); return; } if (Date.now() - start > timeout) { reject(new Error('等待视频元素超时')); return; } setTimeout(check, 300); }; check(); }); } function waitForDuration(video, timeout = 15000) { return new Promise((resolve, reject) => { const start = Date.now(); const check = () => { const d = video.duration; if (d && isFinite(d) && d > 0) { resolve(d); return; } if (d === Infinity) { reject(new Error('直播流无法学习')); return; } if (Date.now() - start > timeout) { reject(new Error('时长加载超时')); return; } setTimeout(check, 300); }; if (video.readyState < 1) { video.addEventListener('loadedmetadata', () => { const d = video.duration; if (d && isFinite(d) && d > 0) resolve(d); else if (d === Infinity) reject(new Error('直播流')); else check(); }, { once: true }); } check(); }); } // ===================== 一键学习 ===================== async function startAutoStudy() { if (isProcessing) { updateStatus('⏳ 执行中...', '#ffd700'); return; } isProcessing = true; studyCompleted = false; updateStatus('⏳ 初始化...', '#ffd700'); const playBtn = getPlayButton(); if (playBtn) { log('点击播放按钮'); playBtn.click(); } let video; try { video = await waitForVideo(); } catch (e) { updateStatus('❌ 视频未找到', '#f88'); alert('未找到视频元素,请刷新后重试'); isProcessing = false; return; } let duration; try { duration = await waitForDuration(video); } catch (e) { updateStatus('❌ ' + e.message, '#f88'); alert(e.message); isProcessing = false; return; } log('总时长:' + formatTime(duration)); const targetTime = Math.max(0, duration - CONFIG.normalEndSeconds); video.currentTime = targetTime; log('跳转至:' + formatTime(targetTime)); try { await video.play(); } catch (e) { updateStatus('⚠️ 点击视频继续', '#ffa500'); await new Promise(resolve => { const handler = () => { video.removeEventListener('click', handler); resolve(); }; video.addEventListener('click', handler); setTimeout(() => { video.removeEventListener('click', handler); resolve(); }, 5000); }); await video.play().catch(() => {}); } video.playbackRate = 1; updateStatus('▶️ 收尾中 (1s)', '#8f8'); updateTimeLeft('⏱ 1s'); startHeartbeat(video); setTimeout(() => { if (!studyCompleted) { studyCompleted = true; stopHeartbeat(); sendHeartbeat(video, true); updateStatus('✅ 完成', '#8f8'); updateTimeLeft('✅ 已完成'); log('完成上报'); } isProcessing = false; }, 1500); video.addEventListener('ended', function onEnded() { if (!studyCompleted) { studyCompleted = true; stopHeartbeat(); sendHeartbeat(video, true); updateStatus('✅ 自然结束', '#8f8'); updateTimeLeft('✅ 已完成'); log('自然结束上报'); } isProcessing = false; this.removeEventListener('ended', onEnded); }); } // ===================== 重置 ===================== function resetVideo() { const video = getVideo(); if (video) { studyCompleted = false; stopHeartbeat(); video.playbackRate = 1; video.currentTime = 0; updateStatus('🔄 已重置', '#8f8'); updateTimeLeft('--:--'); updateReportStatus('已重置', '#8899bb'); isProcessing = false; } } // ===================== 导出诊断日志 ===================== function exportDiagnosticLog() { const video = getVideo(); let logText = '=== 📋 诊断日志 ===\n'; logText += `🕒 ${new Date().toLocaleString()}\n`; logText += `🔗 ${window.location.href}\n\n`; if (video) { logText += `📺 ${getTitle()}\n`; logText += `🆔 ${getLiveId()}\n`; logText += `⏱ ${video.currentTime.toFixed(1)}s / ${video.duration.toFixed(1)}s (${((video.currentTime/video.duration)*100).toFixed(1)}%)\n`; logText += `⚡ ${video.playbackRate}x\n`; } const url = CONFIG.heartbeatUrl || autoDetectedUrl; logText += `🌐 ${url || '未捕获'}\n`; logText += `📤 状态: ${lastReportStatus} ${lastReportTime||''}\n`; if (lastReportPayload) logText += `📦 ${JSON.stringify(lastReportPayload, null, 2)}\n`; if (lastReportError) logText += `❌ ${lastReportError}\n`; navigator.clipboard.writeText(logText).then(() => alert('✅ 已复制诊断日志')); } // ===================== 反馈功能 ===================== function showFeedback() { const mask = document.createElement('div'); mask.style.cssText = ` position:fixed; inset:0; background:rgba(0,0,0,0.75); z-index:99999998; display:flex; align-items:center; justify-content:center; animation: fadeIn 0.3s ease; `; const box = document.createElement('div'); box.style.cssText = ` background: linear-gradient(145deg, #1e2a3a, #0f172a); border-radius: 24px; padding: 28px 24px; max-width: 500px; width: 92%; max-height: 90vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 30px 60px rgba(0,0,0,0.8); color: #fff; font-family: system-ui; text-align: left; `; box.innerHTML = `

📧 反馈与建议

请描述您遇到的问题或建议,我们将认真对待每一条反馈。

💡 点击“复制并发送”会将您的反馈复制到剪贴板,请粘贴至邮件发送至: ${CONFIG.feedbackEmail}

`; mask.appendChild(box); document.body.appendChild(mask); const close = () => mask.remove(); document.getElementById('feedbackCancel').onclick = close; document.getElementById('feedbackSubmit').onclick = function() { const content = document.getElementById('feedbackContent').value.trim(); if (!content) { alert('请填写反馈内容!'); return; } const subject = encodeURIComponent('一键学习脚本反馈'); const body = encodeURIComponent(`反馈内容:\n${content}\n\n---\n用户信息:\n页面: ${window.location.href}\n时间: ${new Date().toLocaleString()}`); // 复制到剪贴板 const fullText = `反馈内容:\n${content}\n\n---\n用户信息:\n页面: ${window.location.href}\n时间: ${new Date().toLocaleString()}`; navigator.clipboard.writeText(fullText).then(() => { alert(`✅ 反馈内容已复制到剪贴板!\n\n请打开邮件客户端,粘贴内容并发送至:\n${CONFIG.feedbackEmail}`); close(); }).catch(() => { // 降级:直接显示mailto window.location.href = `mailto:${CONFIG.feedbackEmail}?subject=${subject}&body=${body}`; close(); }); }; mask.onclick = (e) => { if (e.target === mask) close(); }; } // ===================== 免责声明 ===================== function showDisclaimer() { const mask = document.createElement('div'); mask.style.cssText = ` position:fixed; inset:0; background:rgba(0,0,0,0.8); z-index:99999999; display:flex; align-items:center; justify-content:center; animation: fadeIn 0.3s ease; `; const box = document.createElement('div'); box.style.cssText = ` background: linear-gradient(145deg, #1e2a3a, #0f172a); border-radius: 24px; padding: 30px 28px; max-width: 520px; width: 92%; border: 1px solid rgba(255,215,0,0.2); box-shadow: 0 30px 60px rgba(0,0,0,0.8); color: #fff; font-family: system-ui; text-align: center; `; box.innerHTML = `
⚠️

免责声明

使用本脚本即表示您已阅读并同意以下条款:

`; mask.appendChild(box); document.body.appendChild(mask); document.getElementById('disclaimerConfirm').onclick = function() { mask.remove(); localStorage.setItem('vzan_disclaimer_accepted', '1'); }; mask.onclick = (e) => { if (e.target === mask) { mask.remove(); } }; } // ===================== 使用说明弹窗(原帮助) ===================== function showHelp() { const mask = document.createElement('div'); mask.style.cssText = ` position:fixed; inset:0; background:rgba(0,0,0,0.75); z-index:99999998; display:flex; align-items:center; justify-content:center; animation: fadeIn 0.3s ease; `; const box = document.createElement('div'); box.style.cssText = ` background: linear-gradient(145deg, #1e2a3a, #0f172a); border-radius: 24px; padding: 28px 24px; max-width: 520px; width: 92%; max-height: 80vh; overflow-y: auto; border: 1px solid rgba(255,255,255,0.12); box-shadow: 0 30px 60px rgba(0,0,0,0.8); color: #e2e8f0; font-family: system-ui; font-size: 14px; line-height: 1.8; `; box.innerHTML = `

📖 使用说明

🎯 重要:先点击“播放”按钮,再点击“开始学习”

  1. 打开回放页面,等待视频加载(出现画面和播放按钮)。
  2. 务必先点击页面中的“播放”按钮(视频中间的大圆按钮或底部播放键),让视频开始播放。
  3. 然后点击脚本面板上的 “🚀 开始学习”,脚本将自动跳转至结尾,并完成上报。
  4. 完成后刷新课程列表,查看状态是否更新为“已完成”。

⚠️ 如果跳过第二步,视频可能无法自动播放,导致学习失败。

📋 诊断功能
点击 “📋 诊断” 可一键复制当前视频信息、上报状态、Payload 等,方便反馈问题。

📧 反馈功能
点击 “📧 反馈” 可提交您的问题或建议,方便开发者改进。

⚠️ 注意事项

`; mask.appendChild(box); document.body.appendChild(mask); const close = () => mask.remove(); document.getElementById('help-close-btn').onclick = close; mask.onclick = (e) => { if (e.target === mask) close(); }; } // ===================== 打赏弹窗 ===================== function showDonate() { const mask = document.createElement('div'); mask.style.cssText = ` position:fixed; inset:0; background:rgba(0,0,0,0.75); z-index:99999998; display:flex; align-items:center; justify-content:center; animation: fadeIn 0.3s ease; `; const box = document.createElement('div'); box.style.cssText = ` background: linear-gradient(145deg, #1e2a3a, #0f172a); border-radius: 24px; padding: 28px 24px; max-width: 500px; width: 92%; max-height: 90vh; overflow-y: auto; border: 1px solid rgba(255,215,0,0.2); box-shadow: 0 30px 60px rgba(0,0,0,0.8); color: #fff; font-family: system-ui; text-align: center; `; box.innerHTML = `

💖 感谢您的支持

您的每一次打赏都是作者持续更新的动力!

🙏 脚本永久免费,不限制任何功能。

☕ 如果本工具帮您节省了时间,欢迎请作者喝杯咖啡~

💪 您的支持将激励我持续更新、修复问题。

微信

微信收款码

支付宝

支付宝收款码

打赏金额随意,心意最重要 ❤️

`; mask.appendChild(box); document.body.appendChild(mask); const close = () => mask.remove(); document.getElementById('donate-close-btn').onclick = close; mask.onclick = (e) => { if (e.target === mask) close(); }; } // ===================== UI 面板 ===================== function createPanel() { GM_addStyle(` @keyframes fadeIn { from { opacity:0; transform:scale(0.96); } to { opacity:1; transform:scale(1); } } @keyframes glow { 0% { box-shadow: 0 0 20px rgba(255,215,0,0.1); } 50% { box-shadow: 0 0 40px rgba(255,215,0,0.2); } 100% { box-shadow: 0 0 20px rgba(255,215,0,0.1); } } #study-panel { position: fixed; bottom: 30px; right: 30px; width: 280px; background: linear-gradient(145deg, rgba(20,28,50,0.92), rgba(12,18,34,0.95)); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); border: 1px solid rgba(255,215,0,0.15); border-radius: 20px; padding: 22px 20px 20px; z-index: 99999; font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif; color: #fff; box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,215,0,0.05) inset; user-select: none; cursor: default; transition: box-shadow 0.3s ease; animation: glow 3s ease-in-out infinite; overflow: hidden; } #study-panel::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(ellipse at 30% 20%, rgba(255,215,0,0.03), transparent 70%); pointer-events: none; } #study-panel .panel-header { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 16px; cursor: move; padding: 4px 0; position: relative; z-index: 1; } #study-panel .panel-header .icon { font-size: 22px; } #study-panel .panel-header .title { font-size: 18px; font-weight: 700; background: linear-gradient(135deg, #ffd700, #f5a623); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; letter-spacing: 0.5px; } #study-panel .panel-header .badge { font-size: 10px; background: rgba(255,215,0,0.15); color: #ffd700; padding: 2px 10px; border-radius: 12px; -webkit-text-fill-color: #ffd700; font-weight: 600; } #study-panel .btn-main { display: block; width: 100%; padding: 14px 0; background: linear-gradient(135deg, #f5af19, #f12711); border: none; border-radius: 14px; color: #fff; font-weight: 700; font-size: 18px; cursor: pointer; margin-bottom: 12px; transition: all 0.25s ease; position: relative; z-index: 1; letter-spacing: 0.5px; box-shadow: 0 4px 20px rgba(241, 39, 17, 0.3); } #study-panel .btn-main:hover { transform: translateY(-2px) scale(1.01); box-shadow: 0 8px 30px rgba(241, 39, 17, 0.4); } #study-panel .btn-main:active { transform: scale(0.98); } #study-panel .btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; position: relative; z-index: 1; } #study-panel .btn-sm { flex: 1; min-width: 44px; padding: 7px 0; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; color: #c8d6e5; font-size: 11px; font-weight: 500; cursor: pointer; transition: all 0.2s; text-align: center; font-family: inherit; } #study-panel .btn-sm:hover { background: rgba(255,255,255,0.14); transform: translateY(-1px); } #study-panel .btn-sm.donate { background: rgba(255,215,0,0.08); border-color: rgba(255,215,0,0.15); color: #ffd700; } #study-panel .btn-sm.donate:hover { background: rgba(255,215,0,0.16); } #study-panel .btn-sm.help { background: rgba(100,200,255,0.06); border-color: rgba(100,200,255,0.1); color: #88ddff; } #study-panel .btn-sm.help:hover { background: rgba(100,200,255,0.14); } #study-panel .btn-sm.diagnose { background: rgba(200,200,255,0.05); border-color: rgba(200,200,255,0.08); color: #bbbbff; } #study-panel .btn-sm.diagnose:hover { background: rgba(200,200,255,0.12); } #study-panel .btn-sm.reset { background: rgba(255,200,200,0.05); border-color: rgba(255,200,200,0.08); color: #ff9999; } #study-panel .btn-sm.reset:hover { background: rgba(255,200,200,0.12); } #study-panel .btn-sm.feedback { background: rgba(200,255,200,0.05); border-color: rgba(200,255,200,0.08); color: #88ff88; } #study-panel .btn-sm.feedback:hover { background: rgba(200,255,200,0.12); } #study-panel .info-area { background: rgba(0,0,0,0.25); border-radius: 12px; padding: 10px 12px; margin-top: 2px; position: relative; z-index: 1; } #study-panel .time-left { font-size: 18px; font-weight: 700; text-align: center; color: #ffd700; padding: 2px 0; } #study-panel .status-line { display: flex; justify-content: space-between; font-size: 12px; color: #8899bb; padding: 3px 0; border-top: 1px solid rgba(255,255,255,0.04); margin-top: 4px; } #study-panel .status-line .val { color: #e2e8f0; font-weight: 500; } #study-panel .tiny { font-size: 10px; color: #557799; text-align: center; margin-top: 6px; padding: 4px 6px; background: rgba(0,0,0,0.15); border-radius: 6px; cursor: pointer; transition: color 0.2s; position: relative; z-index: 1; word-break: break-all; } #study-panel .tiny:hover { color: #88ddff; } #study-panel .drag-hint { font-size: 10px; color: #445566; text-align: center; margin-top: 4px; letter-spacing: 0.5px; position: relative; z-index: 1; } `); const panel = document.createElement('div'); panel.id = 'study-panel'; panel.innerHTML = `
一键学习 v3.1
--:--
📡 状态 就绪
📤 上报 未上报
⏳ 捕获心跳地址...
↕ 拖拽标题移动面板
`; document.body.appendChild(panel); // ===================== 修复拖动逻辑 ===================== const dragHandle = document.getElementById('panelDragHandle'); let isDragging = false; let dragStartX = 0; let dragStartY = 0; let panelStartX = 0; let panelStartY = 0; dragHandle.addEventListener('mousedown', function(e) { e.preventDefault(); e.stopPropagation(); const rect = panel.getBoundingClientRect(); panelStartX = rect.left; panelStartY = rect.top; dragStartX = e.clientX; dragStartY = e.clientY; isDragging = true; panel.style.cursor = 'grabbing'; panel.style.transition = 'none'; }); document.addEventListener('mousemove', function(e) { if (!isDragging) return; e.preventDefault(); const dx = e.clientX - dragStartX; const dy = e.clientY - dragStartY; let newX = panelStartX + dx; let newY = panelStartY + dy; const maxX = window.innerWidth - panel.offsetWidth; const maxY = window.innerHeight - panel.offsetHeight; newX = Math.max(0, Math.min(newX, maxX)); newY = Math.max(0, Math.min(newY, maxY)); panel.style.left = newX + 'px'; panel.style.top = newY + 'px'; panel.style.right = 'auto'; panel.style.bottom = 'auto'; }); document.addEventListener('mouseup', function() { if (isDragging) { isDragging = false; panel.style.cursor = 'default'; panel.style.transition = 'box-shadow 0.3s ease'; } }); // ===================== 事件绑定 ===================== document.getElementById('startBtn').addEventListener('click', startAutoStudy); document.getElementById('resetBtn').addEventListener('click', resetVideo); document.getElementById('helpBtn').addEventListener('click', showHelp); document.getElementById('donateBtn').addEventListener('click', showDonate); document.getElementById('diagnoseBtn').addEventListener('click', exportDiagnosticLog); document.getElementById('feedbackBtn').addEventListener('click', showFeedback); // 心跳地址状态更新 setInterval(() => { const url = CONFIG.heartbeatUrl || autoDetectedUrl; const el = document.getElementById('heartbeatInfo'); if (url) { el.textContent = '🌐 ' + url; el.style.color = '#88ddff'; } else { el.textContent = '⏳ 捕获心跳地址...'; el.style.color = '#557799'; } }, 3000); updateStatus('就绪', '#8f8'); updateReportStatus('未上报', '#8899bb'); updateTimeLeft('--:--'); } // ===================== 初始化 ===================== function init() { // 显示免责声明(首次) if (!localStorage.getItem('vzan_disclaimer_accepted')) { showDisclaimer(); } createPanel(); console.log('[一键学习] 面板加载完成,点击“开始学习”前请先点击视频播放按钮'); setTimeout(() => { if (!localStorage.getItem('vzan_help_shown')) { showHelp(); localStorage.setItem('vzan_help_shown', '1'); } }, 1500); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();