ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

慕课培训平台

2022-09-14 12:03:02  阅读:225  来源: 互联网

标签:慕课 console log 平台 querySelector 培训 div document click


// ==UserScript==
// @name         平台培训
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        
// @match        
// @icon         
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    console.log('脚本开始运行!');
    //console.log(window.location.href.indexOf('StudyMain'));/课程列表页面
    //console.log(window.location.href.indexOf('courseware'));/观看视频页面
    //课程页面
    if(window.location.href.indexOf('StudyMain')>-1){
        console.log('课程页面');
        setTimeout(collapse(),5000);
        return;
    }
    //视频学习
    if(window.location.href.indexOf('courseware')>-1){
        console.log('学习页面');
        setTimeout(study(),5000);
        return;
    }
    // Your code here...
})();
function collapse(){
    //折叠菜单
    let tree=document.querySelectorAll('div[class^=tier-tree-one]');
    [].slice.call(tree).forEach((value,index)=>{
        console.log(index);
        console.log(value.getAttribute('class'));
        if(value.getAttribute('class').indexOf('open')>-1)
        {
            value.querySelector('p i').click();
        }
    });
    //展开菜单
    let tree2=document.querySelectorAll('div[class^=tier-tree-one] p i');
    [].slice.call(tree2).forEach((value,index)=>{value.click()});
    //查找未完成
    let fonts=document.querySelectorAll('font.c-blue');
    for(let ft of fonts){
        console.log(ft.parentElement.parentElement.querySelector('span.theme').innerText.includes('学习内容'));
        if(ft.parentElement.parentElement.querySelector('span.theme').innerText.includes('学习内容'))
        {
            //跳转去新课程 font^span^p>span.name>a
            ft.parentElement.parentElement.querySelector('span.name a').click();
            break;
        }
    }
}
function study(){
    //延缓5秒播放
    setTimeout(function(){document.querySelector('div[data-title="点击播放"]').click();},5000);
    let t=setInterval(function(){
        //暂停继续播放
        if(document.querySelector('div[data-title="点击播放"]').getAttribute('style').indexOf('block')>-1){
            console.log('暂停了准备继续……');//提示
            document.querySelector('div[data-title="点击播放"]').click();}
        else
        {
            console.log('播放中……');//提示
        }
        //检查播放完毕
        let arr=document.querySelector('div#videoPlayer div div:nth-child(3) div:nth-child(13)').innerText.split('/');
        if(arr[0].trim()==arr[1].trim() && arr[0].trim()!='00:00:00'){console.log('播放完了');//提示
                                                                      clearInterval(t);//停止计时
                                                                      document.querySelector('div#container p a').click();//返回学习
                                                                     }
        else
        {
            console.log('未播完……');//提示
        }
        //提示弹窗 单击确定
        if(document.querySelector("#panelWindow_confirm_msg").innerText.includes('您')){
            console.log('播放提示……');//提示
            clearInterval(t);//停止计时
            document.querySelector("#panelWindow_confirm > div > p > a.abtn-blue.submit").click();}
    },5000)
    }

  

标签:慕课,console,log,平台,querySelector,培训,div,document,click
来源: https://www.cnblogs.com/nextseven/p/16692532.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有