前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >学习公社平台自动学习脚本

学习公社平台自动学习脚本

作者头像
纯情
发布2023-04-27 10:50:12
2.4K0
发布2023-04-27 10:50:12
举报
文章被收录于专栏:纯情博客

背景

学习公社平台学习中,需要人工干预才可以连续学习。

安装油猴

自己百度

导入脚本

代码语言:javascript
复制
// ==UserScript==
// home.php?mod=space&uid=170990         学习公社平台
// home.php?mod=space&uid=467642    http://tampermonkey.net/
// home.php?mod=space&uid=1248337      0.3
// @description  try to take over the world!
// home.php?mod=space&uid=686208       You
// home.php?mod=space&uid=195849        https://study.enaea.edu.cn/viewerforccvideo.do?courseId=*&circleId=*
// home.php?mod=space&uid=593100         https://www.google.com/s2/favicons?domain=enaea.edu.cn
// home.php?mod=space&uid=609072        none
// ==/UserScript==

(function() {
    'use strict';

    let isLast = false;
     function gotoNext(){
         let todos = opener.$('table.dataTable tr:contains(%)').filter((i,v)=>{ return $(v).find('td:nth-child(4)').text().indexOf('#') == -1 &&  $(v).find('td:nth-child(5)').text().indexOf('100%') == -1})
         .filter((i,v)=>{ let vurl = $(v).find('a.saveStuCourse').attr('data-vurl'); return location.href.indexOf(vurl) == -1});
            if(todos.length > 0){
                console.log('switch to next.... reload  ');
                let nextCourse =  $(todos[0]);
                nextCourse.find('td').eq(3).text('#')
                let nextVurl = nextCourse.find('a.saveStuCourse').attr('data-vurl');
                location.href = nextVurl;
            }
    }

    function autoSetEvent(){
        setInterval(function(){
            var aud = $("div video").get(0);
            if( $(aud).prop('__ok__') != true){
                aud.addEventListener("ended", video_ended);
                console.log("add ended event listener.")
                $(aud).prop('__ok__',true);

                isLast = $('ul.cvtb-MCK-course-list li.last').text() == $('ul.cvtb-MCK-course-list li.current').text();

                let notStudyList = $('div.cvtb-MCK-CsCt-studyProgress').filter((i,v)=>$(v).text().indexOf('100%') == -1);
                if(notStudyList.length == 0){
                    gotoNext();
                }
                else if(notStudyList.length > 0 && $('ul.cvtb-MCK-course-list li.current').find('div.cvtb-MCK-CsCt-studyProgress').text().indexOf('100%') === 0){
                        notStudyList.eq(0).parent().click();
                }
            }

            $('.dialog-button-container button:contains(继续学习)').click()
        },3000);
    }

    function video_ended() {
        console.log("The audio has ended");

        if(isLast){
            console.log('switch to next.... ');       

           gotoNext();
        }
    }

    setTimeout(function(){
        // debugger;
        $(".continue .user_choise").click()
        autoSetEvent();
    },3000);

    // Your code here...
})();
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2022-12-07,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 背景
  • 安装油猴
  • 导入脚本
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档