// ==UserScript== // @name Auto Learning Script // @namespace http://tampermonkey.net/ // @version 0.1 // @description 自动化学习辅助工具 // @author YourName // @match https://*.hnjyxy.com/* // @grant none // ==/UserScript== (function() { 'use strict'; // 配置参数 const config = { username: 'your_username', password: 'your_password', courseId: 'course_id', // 可选指定课程ID delay: 5000, // 操作间隔(毫秒) autoNext: true // 是否自动切换下一课 }; // 登录函数 async function login() { await new Promise(resolve => setTimeout(resolve, config.delay)); // 定位登录表单元素(需根据实际页面结构调整选择器) const usernameInput = document.querySelector('#username'); const passwordInput = document.querySelector('#password'); const submitBtn = document.querySelector('.login-btn'); if (usernameInput && passwordInput && submitBtn) { usernameInput.value = config.username; passwordInput.value = config.password; submitBtn.click(); console.log('登录成功'); } else { console.error('登录元素未找到'); } } // 导航到学习档案 function navigateToLearningProfile() { // 根据实际URL结构修改 window.location.href = '/personal-center/learning-archive'; } // 自动学习函数 async function autoLearn() { await new Promise(resolve => setTimeout(resolve, config.delay)); // 获取课程列表(示例选择器) const courseList = document.querySelectorAll('.course-item'); if (courseList.length === 0) { console.log('没有可学习的课程'); return; } for (const course of courseList) { // 点击课程 course.click(); await new Promise(resolve => setTimeout(resolve, config.delay)); // 开始学习(示例逻辑) const playButton = document.querySelector('.play-btn'); if (playButton) { playButton.click(); console.log('开始学习:', course.textContent); // 等待视频完成(示例检测方式) await new Promise(resolve => { const video = document.querySelector('video'); if (video) { video.addEventListener('ended', resolve, { once: true }); } else { // 如果是H5以外的播放器,可能需要其他检测方式 setTimeout(resolve, 60 * 60 * 1000); // 默认1小时 } }); // 自动切换下一课 if (config.autoNext) { const nextBtn = document.querySelector('.next-course'); if (nextBtn) nextBtn.click(); } } } } // 主执行流程 async function main() { await login(); navigateToLearningProfile(); autoLearn(); } // 启动脚本 main(); })();