吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3108|回复: 41
上一主题 下一主题
收起左侧

[其他原创] 【油猴脚本】学习公社自动完成所有任务

[复制链接]
跳转到指定楼层
楼主
忆白学渣 发表于 2025-2-7 10:08 回帖奖励
本帖最后由 忆白学渣 于 2025-2-7 16:57 编辑

简单的写了个自动完成学习公社的脚本
逻辑简单:主页面点击未学习,等待加载结束,点击第一个学习课程
记录课程时差,刷新,循环
视频界面判断是否关闭当前页面(每10秒检查一次,需要主页面自动刷新)
没写注释,应该可以看懂,主要是延时部分可以自己调一调


使用方法:打开课程页面网址包含p/uc/myClassroom的页面,就什么不需要管了,考虑网络原因设置了加载时差12秒

[Asm] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ==UserScript==
// @name         学习公社刷课脚本
// @version      0.5
// @description  一个用于学习公社刷课 的脚本。
// @author 忆白学渣
// @include      [url=https://www.ttcdw.cn/]https://www.ttcdw.cn/[/url]*
// @grant        none
// ==/UserScript==
async function main() {
    await sleep(12000);
    console.log("等待页面加载完毕");
 
    const currentUrl = window.location.href;
    if (currentUrl.includes('p/uc/myClassroom')) {
        console.log('当前网址为主页面');
        const unlearnedSpan = Array.from(document.querySelectorAll('.col-2 .total')).find(span => span.textContent.trim() === '未学习');
        unlearnedSpan.click();
        await sleep(10000);
        document.getElementsByClassName("btn study-btn")[0].click()
        const time = document.querySelector('.el-table_1_column_2 .cell > div').textContent.trim();
        console.log('时间:', time);
        const timeParts = time.split(':');
        const hours = parseInt(timeParts[0], 10);
        const minutes = parseInt(timeParts[1], 10)+1;
        const seconds = parseInt(timeParts[2], 10);
        const totalSeconds = hours * 3600 + minutes * 60 + seconds;
        await sleep(totalSeconds*1000);
        console.log('页面将在30秒后刷新...');
        setTimeout(() => {
            location.reload();
        }, 30000);
 
    } else {
        console.log('当前网址为视频页。');
        setInterval(checkButtons, 10000);
    }
}
function checkButtons() {
    const closeBtn = document.querySelector('.layui-layer-btn0');
    if (closeBtn) {
        console.log('找到关闭按钮,点击关闭按钮');
        closeBtn.click();
    } else {
        console.log('未找到关闭按钮,检查刷新按钮');
        const refreshBtn = document.querySelector('.layui-layer-btn1');
        if (refreshBtn) {
            console.log('找到刷新按钮,点击刷新按钮');
            refreshBtn.click();
        } else {
            console.log('未找到关闭按钮或刷新按钮,无法执行操作');
        }
    }
}
// 脚本入口
main();
 
// 保持原有的 sleep 函数不变
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

免费评分

参与人数 6吾爱币 +10 热心值 +5 收起 理由
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
jk998 + 1 + 1 热心回复!
shengruqing + 1 我很赞同!
钟爱 + 1 + 1 改造成功
lin5789 + 1 热心回复!
YYL7535 + 1 谢谢@Thanks!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

推荐
lys76 发表于 2025-2-28 13:35
本帖最后由 lys76 于 2025-2-28 13:57 编辑

[JavaScript] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// ==UserScript==
// @name         学习公社刷课脚本
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!
// @AuThor       忆白学渣
// @match        https://www.ttcdw.cn/*
// @Icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==
 
async function main() {
    await sleep(12000);
    console.log("等待页面加载完毕");
 
    const currentUrl = window.location.href;
    if (currentUrl.includes('p/uc/myClassroom')) {
        console.log('当前网址为主页面');
        const unlearnedSpan = Array.from(document.querySelectorAll('.col-2 .total')).find(span => span.textContent.trim() === '未学习');
        unlearnedSpan.click();
        await sleep(8000);
        document.getElementsByClassName("btn study-btn")[0].click()
        const time = document.querySelector('.el-table_1_column_2 .cell > div').textContent.trim();
        console.log('时间:', time);
        const timeParts = time.split(':');
        const hours = parseInt(timeParts[0], 10);
        const minutes = parseInt(timeParts[1], 10)+1;
        const seconds = parseInt(timeParts[2], 10);
        const totalSeconds = hours * 3600 + minutes * 60 + seconds;
        await sleep(totalSeconds*1000);
        console.log('页面将在30秒后刷新...');
        setTimeout(() => {
            location.reload();
        }, 30000);
 
    } else {
        console.log('当前网址为视频页。');
        const myVid=document.querySelector("video");
        if (myVid) {
            myVid.play();
        }
        setInterval(checkStatus, 10000);
    }
}
function checkStatus() {
    const myVid=document.querySelector("video");
    if (myVid.currentTime === myVid.duration) {
        console.log('视频已经学完,即将关闭当前窗口');
        window.close();
    } else {
        console.log('已经播放了',myVid.currentTime.toFixed(2),'秒,还剩',(myVid.duration-myVid.currentTime).toFixed(2),'秒');
    }
}
// 脚本入口
main();
 
// 保持原有的 sleep 函数不变
function sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

按需修改,有需要的自取。
沙发
叶子 发表于 2025-2-7 10:20
3#
toutouxuejishu 发表于 2025-2-7 10:23
4#
cxszhao 发表于 2025-2-7 10:48
给你点赞
5#
钟爱 发表于 2025-2-7 10:52
借你得代码改造一下 刷另一个平台
6#
anan0995 发表于 2025-2-7 11:07
不会用啊  
7#
hlp7777777 发表于 2025-2-7 11:47
我试下看能不能改用到别的平台上使用
8#
gjdir 发表于 2025-2-7 12:05
大佬好,请问有没有  国家智慧教育  的刷课脚本?
9#
chenyong2020 发表于 2025-2-7 12:07
非常不错,我也研究一下看看。
10#
wlbxx 发表于 2025-2-7 12:17
很不错,感谢楼主
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-18 10:31

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表