Greasy Fork

Greasy Fork is available in English.

网梯课堂助手————继续教育网课自动挂机脚本

自动挂机网梯课堂

目前为 2020-07-21 提交的版本,查看 最新版本

// ==UserScript==
// @name         网梯课堂助手————继续教育网课自动挂机脚本
// @namespace    [email protected]
// @version      1.2
// @description  自动挂机网梯课堂
// @author       zfp123123
// @match        http://*.webtrn.cn/learnspace/learn/learn/*/index.action*
// @run-at       document-start
// @require      http://greasyfork.icu/scripts/18715-hooks/code/Hooks.js?version=661566
// @grant        none
// @license      MIT
// ==/UserScript==
function nextP(){

}

function autoPlay() {
    const mainContent = document.getElementsByClassName('contentIframe')[0];
    mainContent.addEventListener("load",function(){
        const mainFrame = mainContent.contentDocument.getElementById("mainFrame");
        mainFrame.addEventListener("load",function(){
            const $ = window.jQuery;
            //视频重新加载时再执行一次脚本
            mainFrame.addEventListener("load",function(){autoPlay();});
            if(location.pathname.indexOf('blue') > -1)
            {
                const menus = [...$(mainContent).contents().find(".vcon").find("li")];            //左侧菜单
                const selectMenu = $(mainContent).contents().find(".vcon").find("li.select")[0];  //当前选中的菜单
                const selectMenuIndex = menus.findIndex(e=>e===selectMenu);                          //当前选中菜单的游标

                const nextBtn = $(mainContent).contents().find(".rtarr")[0];                      //标签栏下一个按钮
                const tabs = [...$(mainContent).contents().find(".menub")];                       //标签栏
                const selectTab = $(mainContent).contents().find(".menubu")[0];                   //当前选中的标签
                const selectTabIndex = tabs.findIndex(e=>e===selectTab);                             //当前选中标签的游标

                nextP = function(){
                    if(tabs.length - selectTabIndex >1){
                        nextBtn.click();
                    }else if(menus.length - selectMenuIndex > 1){
                        menus[selectMenuIndex + 1].click();
                        $(menus[selectMenuIndex + 1]).find("a").click()
                    }
                }
            }else if(location.pathname.indexOf('templatethree') > -1)
            {
                //TODO
            }
            mainFrame.contentDocument.addEventListener('DOMNodeInserted',function(event){
                if(event.target.tagName === 'VIDEO'){
                    const video = event.target;
                    video.addEventListener('playing',function(){
                        video.volume = 0;
                        video.playbackRate = 1.5;
                        video.addEventListener('ended',function(){
                            nextP();
                        });
                    });
                }
            });

            const studyType = $(mainFrame)[0].contentWindow._maq[11][1];
            if(studyType !== 'video')
            {
                nextP();
            }

        });
    });
}

(function() {
    'use strict';
    /**
     * 关闭30分钟每次的检查
     */
    Hooks.set(window, "jQuery", function ( target, propertyName, ignored, jQuery ) {
        Hooks.method(jQuery, "studyTime", function ( target, methodName, method, thisArg, args ) {
            args[0].clickAuth = false;
            args[0].periodRemind = false;
            args[0].randomRemind = false;
            return Hooks.Reply.method( arguments );
        });
        return Hooks.Reply.set( arguments );
    });
    document.addEventListener('DOMContentLoaded',function(){
        autoPlay();
    });
})();