Greasy Fork

Greasy Fork is available in English.

TOD🚀全平台网课助手【学习通 U校园ai 知到 英华 仓辉 雨课堂 职教云】【学起 青书 柠檬 睿学 慕享 出头科技 慕华】【国开 广开 上海开放大学】等平台 客服微信:WKWK796 自动刷课

🐯全网免费仅做一款脚本🐯】、【🚀已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能🚀】【半兼容、绎通云、U校园、学堂在线】、【😎完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时长不存在滴)、视频倍速😎】、

当前为 2025-11-01 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         TOD🚀全平台网课助手【学习通 U校园ai 知到 英华 仓辉 雨课堂 职教云】【学起 青书 柠檬 睿学 慕享 出头科技 慕华】【国开 广开 上海开放大学】等平台 客服微信:WKWK796  自动刷课
// @namespace    https://github.com/wkwk796
// @version      2.7.4
// @description  🐯全网免费仅做一款脚本🐯】、【🚀已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能🚀】【半兼容、绎通云、U校园、学堂在线】、【😎完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时长不存在滴)、视频倍速😎】、
// @author       Wkwk796
// @match        *://*.chaoxing.com/*
// @match        *://*.zhihuishu.com/*
// @match        *://*.chaoxing.com/*
// @match        *://mooc1.chaoxing.com/nodedetailcontroller/*
// @match        *://*.chaoxing.com/mooc-ans/work/doHomeWorkNew*
// @match        *://*.chaoxing.com/work/doHomeWorkNew*
// @match        *://*.edu.cn/work/doHomeWorkNew*
// @match        *://*.asklib.com/*
// @match        *://*.chaoxing.com/*
// @match        *://*.hlju.edu.cn/*
// @match        *://lms.ouchn.cn/*
// @match        *://xczxzdbf.moodle.qwbx.ouchn.cn/*
// @match        *://tongyi.aliyun.com/qianwen/*
// @match        *://chatglm.cn/*
// @match        *://*.zhihuishu.com/*
// @match        *://course.ougd.cn/*
// @match        *://moodle.syxy.ouchn.cn/*
// @match        *://moodle.qwbx.ouchn.cn/*
// @match        *://elearning.bjou.edu.cn/*
// @match        *://whkpc.hnqtyq.cn:5678/*
// @match        *://study.ouchn.cn/*
// @match        *://www.51xinwei.com/*
// @match        *://*.w-ling.cn/*
// @match        *://xuexi.jsou.cn/*
// @match        *://*.edu-edu.com/*
// @match        *://xuexi.jsou.cn/*
// @match        *://spoc-exam.icve.com.cn/*
// @match        *://*.icve.com.cn/*
// @match        *://zice.cnzx.info/*
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_info
// @grant        GM_addStyle
// @grant        unsafeWindow
// @grant        none
// @license      MIT
// @icon         https://static.zhihuishu.com/static/img/favicon.ico
// ==/UserScript==

(function() {
    'use strict';

    // 配置项
    const config = {
        autoPlay: GM_getValue('autoPlay', true),
        autoMute: GM_getValue('autoMute', true),
        autoNext: GM_getValue('autoNext', true),
        showContact: GM_getValue('showContact', true),
        customSpeed: parseFloat(GM_getValue('customSpeed', 1.0)),
        skipCompleted: GM_getValue('skipCompleted', true),
        disableMonitor: GM_getValue('disableMonitor', false),
        contactInfo: 'wkwk796'
    };

    // 保存配置
    function saveConfig() {
        try {
            GM_setValue('autoPlay', config.autoPlay);
            GM_setValue('autoMute', config.autoMute);
            GM_setValue('autoNext', config.autoNext);
            GM_setValue('showContact', config.showContact);
            GM_setValue('customSpeed', config.customSpeed);
            GM_setValue('skipCompleted', config.skipCompleted);
            GM_setValue('disableMonitor', config.disableMonitor);
        } catch (e) {
            console.error('保存配置失败:', e);
        }
    }

    // 显示通知
    function showNotification(message, type = 'info') {
        try {
            if (!document || !document.body) return;
            
            const notification = document.createElement('div');
            notification.className = 'chaoxing-notification notification-' + type;
            notification.textContent = message;
            
            document.body.appendChild(notification);
            
            setTimeout(() => {
                notification.classList.add('fade-out');
                setTimeout(() => {
                    if (document.body && document.body.contains(notification)) {
                        document.body.removeChild(notification);
                    }
                }, 300);
            }, 3000);
        } catch (e) {
            console.error('显示通知失败:', e);
        }
    }

    // 创建控制面板
    function createControlPanel() {
        try {
            if (!document || !document.body) return;
            
            // 检查是否已存在控制面板
            const existingPanel = document.getElementById('chaoxing-auto-play-panel');
            if (existingPanel) {
                existingPanel.style.display = 'block';
                return;
            }

            const panel = document.createElement('div');
            panel.id = 'chaoxing-auto-play-panel';
            
            // 使用字符串拼接避免语法问题
            let panelHTML = '';
            panelHTML += '<div class="chaoxing-panel-header">';
            panelHTML += '    <h3>学习通视频助手控制面板</h3>';
            panelHTML += '    <button id="chaoxing-close-panel">×</button>';
            panelHTML += '</div>';
            panelHTML += '<div class="chaoxing-panel-body">';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            <input type="checkbox" id="chaoxing-auto-play"' + (config.autoPlay ? ' checked' : '') + '>';
            panelHTML += '            自动播放视频';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            <input type="checkbox" id="chaoxing-auto-mute"' + (config.autoMute ? ' checked' : '') + '>';
            panelHTML += '            自动静音';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            <input type="checkbox" id="chaoxing-auto-next"' + (config.autoNext ? ' checked' : '') + '>';
            panelHTML += '            自动播放下一节';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            <input type="checkbox" id="chaoxing-skip-completed"' + (config.skipCompleted ? ' checked' : '') + '>';
            panelHTML += '            跳过已完成视频';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            <input type="checkbox" id="chaoxing-disable-monitor"' + (config.disableMonitor ? ' checked' : '') + '>';
            panelHTML += '            禁用多端监控';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            panelHTML += '    <div class="chaoxing-control-item">';
            panelHTML += '        <label>';
            panelHTML += '            播放速度:';
            panelHTML += '            <select id="chaoxing-playback-speed">';
            panelHTML += '                <option value="0.5"' + (config.customSpeed === 0.5 ? ' selected' : '') + '>0.5x</option>';
            panelHTML += '                <option value="1.0"' + (config.customSpeed === 1.0 ? ' selected' : '') + '>1.0x</option>';
            panelHTML += '                <option value="1.25"' + (config.customSpeed === 1.25 ? ' selected' : '') + '>1.25x</option>';
            panelHTML += '                <option value="1.5"' + (config.customSpeed === 1.5 ? ' selected' : '') + '>1.5x</option>';
            panelHTML += '                <option value="2.0"' + (config.customSpeed === 2.0 ? ' selected' : '') + '>2.0x</option>';
            panelHTML += '                <option value="3.0"' + (config.customSpeed === 3.0 ? ' selected' : '') + '>3.0x</option>';
            panelHTML += '                <option value="4.0"' + (config.customSpeed === 4.0 ? ' selected' : '') + '>4.0x</option>';
            panelHTML += '            </select>';
            panelHTML += '        </label>';
            panelHTML += '    </div>';
            
            // 添加联系方式
            panelHTML += '    <div class="chaoxing-contact-info">';
            panelHTML += '        <p>开发者联系方式: ' + config.contactInfo + '</p>';
            panelHTML += '    </div>';
            
            panelHTML += '    <div class="chaoxing-panel-footer">';
            panelHTML += '        <button id="chaoxing-toggle-contact">' + (config.showContact ? '隐藏联系方式' : '显示联系方式') + '</button>';
            panelHTML += '        <button id="chaoxing-refresh-video">刷新视频检测</button>';
            panelHTML += '    </div>';
            panelHTML += '</div>';
            
            panel.innerHTML = panelHTML;
            document.body.appendChild(panel);

            // 添加事件监听器
            setupPanelEventListeners(panel);
        } catch (e) {
            console.error('创建控制面板失败:', e);
        }
    }

    // 设置面板事件监听器
    function setupPanelEventListeners(panel) {
        try {
            const closeBtn = document.getElementById('chaoxing-close-panel');
            if (closeBtn) {
                closeBtn.addEventListener('click', () => {
                    panel.style.display = 'none';
                });
            }

            const autoPlayCheckbox = document.getElementById('chaoxing-auto-play');
            if (autoPlayCheckbox) {
                autoPlayCheckbox.addEventListener('change', (e) => {
                    config.autoPlay = e.target.checked;
                    saveConfig();
                    if (config.autoPlay) {
                        checkAndPlayVideos();
                    }
                });
            }

            const autoMuteCheckbox = document.getElementById('chaoxing-auto-mute');
            if (autoMuteCheckbox) {
                autoMuteCheckbox.addEventListener('change', (e) => {
                    config.autoMute = e.target.checked;
                    saveConfig();
                    // 如果启用静音,立即将所有视频设为静音
                    if (config.autoMute && document) {
                        const videos = document.querySelectorAll('video');
                        videos.forEach(video => {
                            if (video && video.volume !== undefined) {
                                video.muted = true;
                            }
                        });
                    }
                });
            }

            const autoNextCheckbox = document.getElementById('chaoxing-auto-next');
            if (autoNextCheckbox) {
                autoNextCheckbox.addEventListener('change', (e) => {
                    config.autoNext = e.target.checked;
                    saveConfig();
                });
            }

            const skipCompletedCheckbox = document.getElementById('chaoxing-skip-completed');
            if (skipCompletedCheckbox) {
                skipCompletedCheckbox.addEventListener('change', (e) => {
                    config.skipCompleted = e.target.checked;
                    saveConfig();
                });
            }

            const disableMonitorCheckbox = document.getElementById('chaoxing-disable-monitor');
            if (disableMonitorCheckbox) {
                disableMonitorCheckbox.addEventListener('change', (e) => {
                    config.disableMonitor = e.target.checked;
                    saveConfig();
                    if (config.disableMonitor) {
                        disablePageMonitor();
                    }
                });
            }

            const playbackSpeedSelect = document.getElementById('chaoxing-playback-speed');
            if (playbackSpeedSelect) {
                playbackSpeedSelect.addEventListener('change', (e) => {
                    config.customSpeed = parseFloat(e.target.value);
                    saveConfig();
                    setPlaybackSpeed();
                });
            }

            const toggleContactBtn = document.getElementById('chaoxing-toggle-contact');
            if (toggleContactBtn) {
                toggleContactBtn.addEventListener('click', () => {
                    config.showContact = !config.showContact;
                    saveConfig();
                    const contactInfo = document.querySelector('.chaoxing-contact-info');
                    if (contactInfo) {
                        contactInfo.style.display = config.showContact ? 'block' : 'none';
                    }
                    toggleContactBtn.textContent = config.showContact ? '隐藏联系方式' : '显示联系方式';
                });
            }

            const refreshVideoBtn = document.getElementById('chaoxing-refresh-video');
            if (refreshVideoBtn) {
                refreshVideoBtn.addEventListener('click', () => {
                    checkAndPlayVideos();
                    showNotification('视频检测已刷新', 'success');
                });
            }
        } catch (e) {
            console.error('设置面板事件监听器失败:', e);
        }
    }

    // 检查并播放视频
    function checkAndPlayVideos() {
        try {
            if (!document || !config.autoPlay) return;

            // 查找所有视频元素
            const videos = document.querySelectorAll('video');
            videos.forEach(video => {
                if (!video || !video.tagName) return;
                
                // 设置静音
                if (config.autoMute && video.muted !== undefined) {
                    video.muted = true;
                }
                
                // 设置播放速度
                if (video.playbackRate !== undefined) {
                    video.playbackRate = config.customSpeed;
                }
                
                // 自动播放
                if (video.paused && video.play !== undefined) {
                    try {
                        video.play().catch(err => {
                            console.log('视频播放失败,尝试备用方法:', err);
                            // 尝试模拟用户交互后播放
                            setTimeout(() => {
                                try {
                                    video.play();
                                } catch (e) {
                                    console.error('备用播放方法也失败:', e);
                                }
                            }, 100);
                        });
                    } catch (e) {
                        console.error('播放视频时出错:', e);
                    }
                }
            });

            // 处理学习通特有的播放器
            handleChaoxingPlayers();
        } catch (e) {
            console.error('检查并播放视频失败:', e);
        }
    }

    // 处理学习通特有的播放器
    function handleChaoxingPlayers() {
        try {
            if (!document) return;

            // 查找学习通播放器容器
            const playerContainers = document.querySelectorAll('.vjs-tech, #video, .d_player, .video-box');
            
            playerContainers.forEach(container => {
                if (!container) return;
                
                // 查找播放按钮并点击
                const playButtons = container.querySelectorAll('.vjs-play-control, .vjs-big-play-button, .d-play-btn, .playBtn, .startBtn');
                playButtons.forEach(btn => {
                    if (btn && !btn.disabled && btn.style.display !== 'none') {
                        try {
                            btn.click();
                        } catch (e) {
                            // 静默失败
                        }
                    }
                });
            });

            // 处理进度条拖拽(跳过广告或已观看内容)
            if (config.skipCompleted) {
                const progressBars = document.querySelectorAll('.vjs-progress-control, .d-progress-bar, .progress-bar, .progress');
                progressBars.forEach(bar => {
                    if (bar) {
                        try {
                            const rect = bar.getBoundingClientRect();
                            // 模拟点击进度条中间位置
                            const clickEvent = new MouseEvent('click', {
                                clientX: rect.left + rect.width * 0.5,
                                clientY: rect.top + rect.height * 0.5,
                                bubbles: true,
                                cancelable: true
                            });
                            bar.dispatchEvent(clickEvent);
                        } catch (e) {
                            // 静默失败
                        }
                    }
                });
            }
        } catch (e) {
            console.error('处理学习通播放器失败:', e);
        }
    }

    // 设置播放速度
    function setPlaybackSpeed() {
        try {
            if (!document) return;

            // 设置所有视频元素的播放速度
            const videos = document.querySelectorAll('video');
            videos.forEach(video => {
                if (video && video.playbackRate !== undefined) {
                    video.playbackRate = config.customSpeed;
                }
            });

            // 尝试通过学习通的速度控制功能设置
            const speedControls = document.querySelectorAll('.speed-btn, .playback-speed');
            speedControls.forEach(control => {
                if (control) {
                    try {
                        // 尝试点击速度控制按钮
                        control.click();
                        // 然后选择对应速度的选项
                        const speedOptions = document.querySelectorAll('.speed-option, .speed-item');
                        speedOptions.forEach(option => {
                            if (option && option.textContent && option.textContent.includes(config.customSpeed + 'x')) {
                                setTimeout(() => option.click(), 100);
                            }
                        });
                    } catch (e) {
                        // 静默失败
                    }
                }
            });
        } catch (e) {
            console.error('设置播放速度失败:', e);
        }
    }

    // 禁用页面监控
    function disablePageMonitor() {
        try {
            // 禁用常见的窗口失焦检测
            if (unsafeWindow) {
                // 备份原始方法
                const originalBlur = unsafeWindow.onblur;
                const originalVisibilityChange = document.visibilityState;
                
                // 覆盖失焦检测
                Object.defineProperty(document, 'visibilityState', {
                    get: () => 'visible',
                    configurable: true
                });
                
                document.addEventListener('visibilitychange', (e) => {
                    e.stopPropagation();
                    e.preventDefault();
                }, true);
                
                window.addEventListener('blur', (e) => {
                    e.stopPropagation();
                    e.preventDefault();
                }, true);
                
                window.addEventListener('focusout', (e) => {
                    e.stopPropagation();
                    e.preventDefault();
                }, true);
            }

            // 阻止页面卸载确认
            window.addEventListener('beforeunload', (e) => {
                e.stopPropagation();
                e.preventDefault();
            }, true);

            showNotification('多端监控已禁用', 'success');
        } catch (e) {
            console.error('禁用页面监控失败:', e);
        }
    }

    // 检查是否需要自动播放下一节
    function checkNextVideo() {
        try {
            if (!document || !config.autoNext) return;

            // 检测视频是否播放完毕
            const videos = document.querySelectorAll('video');
            let allVideosEnded = true;
            
            videos.forEach(video => {
                if (video && !video.ended) {
                    allVideosEnded = false;
                }
            });

            // 如果所有视频都播放完毕,尝试查找并点击下一节按钮
            if (allVideosEnded) {
                const nextButtons = document.querySelectorAll(
                    '.next-btn, .nextChapter, .nextVideo, .next-step, ' +
                    '[id*="next"], [class*="next"], [data-role="next"], ' +
                    '.ant-btn-next, .btn-next, .next-btn-primary'
                );
                
                nextButtons.forEach(btn => {
                    if (btn && !btn.disabled && btn.style.display !== 'none') {
                        try {
                            btn.click();
                            showNotification('自动播放下一节', 'success');
                        } catch (e) {
                            // 静默失败
                        }
                    }
                });
            }
        } catch (e) {
            console.error('检查下一节视频失败:', e);
        }
    }

    // 处理动态加载的内容
    function handleDynamicContent() {
        try {
            // 使用 MutationObserver 监控 DOM 变化
            const observer = new MutationObserver((mutations) => {
                mutations.forEach(mutation => {
                    if (mutation.addedNodes && mutation.addedNodes.length > 0) {
                        // 检查是否有新的视频元素被添加
                        let hasVideo = false;
                        mutation.addedNodes.forEach(node => {
                            if (node.nodeType === 1) { // Element node
                                if (node.tagName === 'VIDEO' || node.querySelector('video')) {
                                    hasVideo = true;
                                }
                                // 检查学习通特有的播放器容器
                                const playerSelectors = '.vjs-tech, #video, .d_player, .video-box';
                                if (node.querySelector(playerSelectors)) {
                                    hasVideo = true;
                                }
                            }
                        });
                        
                        if (hasVideo) {
                            setTimeout(checkAndPlayVideos, 500);
                        }
                    }
                });
            });

            // 开始监控
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        } catch (e) {
            console.error('处理动态内容失败:', e);
        }
    }

    // 添加样式
    function addStyles() {
        try {
            GM_addStyle(`
                /* 控制面板样式 */
                #chaoxing-auto-play-panel {
                    position: fixed;
                    top: 50px;
                    right: 20px;
                    width: 300px;
                    background: rgba(255, 255, 255, 0.95);
                    border: 1px solid #ddd;
                    border-radius: 8px;
                    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
                    z-index: 999999;
                    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
                }
                
                .chaoxing-panel-header {
                    padding: 15px;
                    background: #4CAF50;
                    color: white;
                    border-radius: 8px 8px 0 0;
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                }
                
                .chaoxing-panel-header h3 {
                    margin: 0;
                    font-size: 16px;
                    font-weight: 600;
                }
                
                #chaoxing-close-panel {
                    background: none;
                    border: none;
                    color: white;
                    font-size: 24px;
                    cursor: pointer;
                    padding: 0;
                    width: 30px;
                    height: 30px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    border-radius: 50%;
                    transition: background 0.2s;
                }
                
                #chaoxing-close-panel:hover {
                    background: rgba(255, 255, 255, 0.2);
                }
                
                .chaoxing-panel-body {
                    padding: 20px;
                }
                
                .chaoxing-control-item {
                    margin-bottom: 15px;
                    display: flex;
                    align-items: center;
                }
                
                .chaoxing-control-item label {
                    display: flex;
                    align-items: center;
                    cursor: pointer;
                    user-select: none;
                    font-size: 14px;
                    color: #333;
                }
                
                .chaoxing-control-item input[type="checkbox"] {
                    margin-right: 8px;
                    width: 16px;
                    height: 16px;
                    cursor: pointer;
                }
                
                .chaoxing-control-item select {
                    margin-left: 8px;
                    padding: 4px 8px;
                    border: 1px solid #ddd;
                    border-radius: 4px;
                    font-size: 14px;
                    cursor: pointer;
                }
                
                .chaoxing-contact-info {
                    margin: 20px 0;
                    padding: 10px;
                    background: #f5f5f5;
                    border-radius: 4px;
                    text-align: center;
                }
                
                .chaoxing-contact-info p {
                    margin: 0;
                    font-size: 14px;
                    color: #666;
                }
                
                .chaoxing-panel-footer {
                    display: flex;
                    justify-content: space-between;
                    margin-top: 20px;
                }
                
                .chaoxing-panel-footer button {
                    padding: 8px 16px;
                    background: #4CAF50;
                    color: white;
                    border: none;
                    border-radius: 4px;
                    cursor: pointer;
                    font-size: 14px;
                    transition: background 0.2s;
                }
                
                .chaoxing-panel-footer button:hover {
                    background: #45a049;
                }
                
                /* 通知样式 */
                .chaoxing-notification {
                    position: fixed;
                    top: 20px;
                    right: 20px;
                    padding: 15px 20px;
                    background: #333;
                    color: white;
                    border-radius: 4px;
                    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
                    z-index: 999999;
                    font-size: 14px;
                    transition: opacity 0.3s, transform 0.3s;
                    transform: translateY(0);
                }
                
                .chaoxing-notification.notification-success {
                    background: #4CAF50;
                }
                
                .chaoxing-notification.notification-error {
                    background: #f44336;
                }
                
                .chaoxing-notification.notification-warning {
                    background: #ff9800;
                }
                
                .chaoxing-notification.fade-out {
                    opacity: 0;
                    transform: translateY(-10px);
                }
            `);
        } catch (e) {
            console.error('添加样式失败:', e);
        }
    }

    // 主函数
    function init() {
        try {
            // 等待页面加载完成
            if (document.readyState === 'loading') {
                document.addEventListener('DOMContentLoaded', () => {
                    addStyles();
                    createControlPanel();
                    handleDynamicContent();
                    
                    // 初始检查视频
                    setTimeout(checkAndPlayVideos, 1000);
                    
                    // 定期检查视频状态
                    setInterval(() => {
                        checkAndPlayVideos();
                        checkNextVideo();
                    }, 3000);
                });
            } else {
                // 页面已经加载完成
                addStyles();
                createControlPanel();
                handleDynamicContent();
                
                // 初始检查视频
                setTimeout(checkAndPlayVideos, 1000);
                
                // 定期检查视频状态
                setInterval(() => {
                    checkAndPlayVideos();
                    checkNextVideo();
                }, 3000);
            }

            // 注册菜单命令
            try {
                GM_registerMenuCommand('显示控制面板', () => {
                    const panel = document.getElementById('chaoxing-auto-play-panel');
                    if (panel) {
                        panel.style.display = 'block';
                    } else {
                        createControlPanel();
                    }
                });
                
                GM_registerMenuCommand('刷新视频检测', checkAndPlayVideos);
            } catch (e) {
                console.log('GM_registerMenuCommand 不可用:', e);
            }
        } catch (e) {
            console.error('初始化脚本失败:', e);
        }
    }

    // 启动脚本
    init();

})();