兰交大实验室学习助手

自动滚动并完成学习内容。

当前为 2024-10-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         兰交大实验室学习助手
// @namespace    http://tampermonkey.net/
// @version      2.9
// @description  自动滚动并完成学习内容。
// @author       白白小草
// @match        http://webvpn.lzjtu.edu.cn/http/*/safe/client_pc/sd*
// @match        http://labmis.lzjtu.edu.cn/safe/client_pc/sd*
// @match        https://weread.qq.com/web/reader/*
// @match        https://labsafe.lzjtu.edu.cn/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=baidu.com
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function learnNext(rows,learnedCount) {
        console.log("开始学习");
        // 找到第一个未学习的tr
        let currentRow = Array.from(rows).find(row => !row.classList.contains('已学习'));

        if (currentRow && learnedCount < 10) {
            console.log("已找到第一个未学习页面");
            const button = currentRow.getElementsByTagName('td')[3].getElementsByTagName('button')[0]; // 获取按钮
            button.click(); // 点击按钮

            // 获取时长
            const durationText = currentRow.getElementsByTagName('td')[2].innerText; // 假设第三个td是时长
            const totalDuration = durationText.split('/')[1].trim(); // 取出"/"后的时长
            const [h, m, s] = totalDuration.split(':').map(Number);
            const totalSeconds = h * 3600 + m * 60 + s + 15; // 加上15秒
            console.log("学习:", totalSeconds, "秒");

            setTimeout(() => {
                // 标记为已学习
                currentRow.classList.add('已学习');
                learnedCount++;
                // 点击返回按钮
                const returnButton = document.querySelector('button.ivu-btn-text'); // 根据类名查找返回按钮
                if (returnButton) {
                    returnButton.click(); // 点击返回按钮
                }

                // 等待返回后重新调用学习
                setTimeout(() => {
                    startLearning(); // 重新启动学习流程
                }, 1000); // 等待1秒后重新开始学习
            }, totalSeconds * 1000); // 转换为毫秒
        } else if (learnedCount >= 10) {
            // 学习完10个后返回到上一页面并刷新
            setTimeout(() => {
                location.reload(); // 刷新页面
            }, 1000); // 延迟1秒刷新,确保页面加载完成
        }
    }

    function startLearning() {
        const tbody = document.getElementsByClassName('ivu-table-tbody')[0];

        if (tbody && tbody.getElementsByTagName('tr').length > 0) {
            const rows = tbody.getElementsByTagName('tr');
            let learnedCount = 0;

            learnNext(rows,learnedCount); // 开始学习
        } else {
            // 列表为空,可能需要等待一段时间后重试
            setTimeout(startLearning, 1000); // 每秒检查一次
        }
    }

    window.onload = function() {
        startLearning(); // 启动学习流程
    };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址