Greasy Fork

(21tb)时代光华课程自动播放

learning

目前为 2022-11-05 提交的版本。查看 最新版本

// ==UserScript==
// @license      Peng
// @name         (21tb)时代光华课程自动播放
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  learning
 
// @author       Peng
// @match        *://*.21tb.com/*
// ==/UserScript==
 
      (function() {
        'use strict';
        function next(){
 
 
 
            let all_item = document.querySelectorAll('.section-item .first-line') //总节数
            var all_tig_item = document.querySelectorAll('.finish-tig-item') //已完成和进行中
 
            if (all_item != null && all_item.length > 0) {
                console.log("共 " + all_item.length + " 节课")
                if (all_tig_item != null && all_tig_item.length > 0) {
                    var index = all_tig_item.length
                    var done = 0;
                    for (let i = 0; i < index; i++) {
                        if (all_tig_item[i].textContent.includes('已完成')) {
                            done++
                        }
                    }
 
                    console.log("index:" + index + ", done:" + done)
 
                    if (done == index){
                        for (let j = 0; j < all_item.length; j++) {
                            if (all_item[j].textContent.includes('已完成') == false) {
                                all_item[j].click()
                                console.log("下一节 播放完成!")
                                break;
                            }
                        }
                    }
                }
            }
 
 
 
        }
        setInterval(next,10000)
        
      })();