F蓝天

教学系统挂机插件

// ==UserScript==
// @name         F蓝天
// @namespace    https://ty.ji56.cn/temp/Flantian.user.js
// @version      1.0.1
// @description  教学系统挂机插件
// @author       Win
// @match        *://v3.lt-edu.net/*
// @match        *://www.runoob.com/*
// @icon         data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAMAAAD04JH5AAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAMAUExURUxpcQCI/////wKJ/0Cm/xmU/xaS/+33/9fs/0So/wSK/w2O/wCI/wGI/9/w/wCI/+/4/1Ct/wCI/wiM/xWS/+r1//H4/waL/+33/xGQ/wCI/5/S/4XG//f7/6/a//3+/x2W//b7/xmU/xCP/yCX/7Xc/wuN/1Ov/3a//7Hb/y6e/w6P/5/T/2+8//3+//7///r8/3fA/weL/zOg/xKQ/9/w//n8/xyV/+j0/9nt/ymb//X6//v9/3zC/9vu/4PF//L5/+Hx/zei/6LU/wmN/wGJ//D4/wKJ/9Hp/0Kn/ySZ/wCI/wCI/5/S/1Ct/1Ct/4/L/wCI/2C1/7/h/yKY/2y6/0ap/yea/8bl/1uz/xOR/xeT/+Tz/4fH/+z2/xCQ/1qy/3G9/3/D/5jP/8rm/+bz//7//0+t/7rf/1ix/6nX/5HM/xWS/3vB/7Lb/83o/2O2/+Xz/67a/1yz/2i5/yOY/0ys/9Dp//P5/1ew/77h/02s/3O+/4DE/7bd/5vQ/8Hi/z2k/1+1/yCX/yyd//z9/1Ct/5XN/+n1/3nA/zmi/33C/zuk/2O2/2W3/6jW/160/9bs/7je/3C8/9Tr/8Li/4/L/5rQ/5TN/4rJ/2G2/97w/y+e/9bs/7zg/zah/2i5/+f0/2G2/wCI/9Xr/9zv/9Lq/2y7/4zJ/2W4/xCP/+f0/0iq/yeb/7ne/6/a/0So/+n1/8Lj/xeT/6fW/9Pr/0Cm/8jl/2q6/43K/2m5/+v2/+Lx/+bz/zqj/9ru/8fl/xaS/1aw/6TV/53S/47K/wCI/wCI/7/h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f9jOYurWNxn5ErXi9PgD/7X3wBkYbynYYSV5nTC/DqhISCAB8Z8FEUZmh0A0iSN97HHkLJrC/LzQC0LgOJoquNxy6QUQFDNL6Hj1VCdoAeJ1LUr3xhBtRCYd1wwGsKiFcD8CG2pFg3NZKkpQjYRGLvapyD69KwAEexSLJdSFkNX7EZTx282C83qrluAZAG5YoKv7CjlAvh0ImZt8CLGuRwwwAaCSKNuaQF1lyKuViVrRAO3/+pvz7Ap4oClrBpcaTazEbfqOV8juXohWhAAiFr5LJ9YlsVThXdXwKGveM6NRpvrN3D3dl/Eo6C9fFa5mPr+7go4pvUavvej/MvN/lBH6K+Jf1lr6qTm2P+amUrxohhc0lqlIjz9QS/kqElXZXpOyXu+t0lsgBBBa3Zw/6TtB8hnZ5fx79BgfqLR7Um1yot/lQb3Si3upFv9mNZrvfv8qGx5207O9Utd7updXyuXeg6TWPyi6c/99p+6Xf+Ey/9ZuV8+Zsfj+vs//e6WJB4IXTprV9+kJgwUXY/n8VcT7RF5AmQAgAAAAASUVORK5CYII=
// @grant        none
// @require      https://cdn.bootcss.com/jquery/3.5.1/jquery.min.js
// ==/UserScript==
(function() {
    'use strict';
    console.log('开始啦');
    setTimeout(function(){
        //$("video").trigger('play');
        plays();
        //requests();
    },"1000");

    //1秒检测一次
    setInterval(function(){
        //obsClick('.el-message-box__btns > button > .el-button--primary');
        clickDOM(".v-modal",".el-message-box__btns button.el-button--primary");
        plays();
        // 是否播放结束
        checkPlayEnd();
    },"1000");


    document.addEventListener('visibilitychange', function() {
        //console.log(document.visibilityState)
        switch(document.visibilityState) {
            case 'prerender':
                console.log('网页预渲染,内容不可见')
                break;
            case 'hidden':
                console.log('内容不可见,处理后台、最小化、锁屏状态')
                plays()
                //document.getElementsByTagName('video')[0].playbackRate = 4
                //$("#video video").play();
                break;
            case 'visible':
                plays()
                console.log('处于正常打开')
                break;
        }
    })
    //立即播放
    function plays(){
        setTimeout(function(){
            $("video").trigger('play');

            var elems = document.querySelectorAll("video, audio");
            [].forEach.call(elems, function(elem) { elem.muted = true; });
        },"1500");
    }

    /**
    点击
    **/
    function clickDOM(checkSelector,clickSelector){
        let target = document.querySelector(checkSelector);
        let clickTarget = document.querySelector(clickSelector);
        if(!!target){
            clickTarget.click();
        }
    }

    //检测播放结束
    function checkPlayEnd(){
        let video=document.querySelector("video");
        video.addEventListener("ended", function() {

            var allNum=$(".swiper-slide").length;
            $(".video-status.study").parent(".swiper-slide").next(function(){
                var nowNum=$(this);
                console.log("播放结束",allNum,nowNum);
                this.trigger('video-status');
            });
        })
    }

    /**
 * 监测到节点后点击
 * @param selector    CSS选择器
 * @param time    延时,负数:延时->执行,正数:执行->延时
 * @param desc
 * @returns {Promise<unknown>}
 */
    function obsClick(selector, time = 0, desc = 'obsClick') {
        return new Promise(resolve => {
            //obs node
            let timer = setInterval(() => {
                let target = document.querySelector(selector)
                if (!!target) {
                    clearInterval(timer)
                    if (time < 0) {
                        setTimeout(() => {
                            target.click()
                            console.log(desc, selector)
                            resolve(selector)
                        }, Math.abs(time) * 1000)
                    } else if (time > 0) {
                        target.click()
                        setTimeout(() => {
                            console.log(desc, selector)
                            resolve(selector)
                        }, Math.abs(time) * 1000)
                    } else {
                        target.click()
                        console.log(desc, selector)
                        resolve(selector)
                    }
                } else {
                    return
                }
            }, 100)
            })
    }

    /**
 * 监测节点是否存在
 * @param selector    CSS选择器
 * @param time    延时,负数:延时->执行,正数:执行->延时
 * @param desc
 * @returns {Promise<unknown>}
 */
    function obsHas(selector, time = 0, desc = 'obsHas') {
        return new Promise(resolve => {
            //obs node
            let timer = setInterval(() => {
                let target = document.querySelector(selector)
                if (!!target) {
                    clearInterval(timer)
                    if (Math.abs(time) > 0) {
                        setTimeout(() => {
                            console.log(desc, selector)
                            resolve(selector)
                        }, Math.abs(time) * 1000)
                    } else {
                        console.log(desc, selector)
                        resolve(selector)
                    }
                } else {
                    return
                }
            }, 100)
            })
    }

    //请求
    function requests(url,method){
        method=!!method?method:"get";
        GM_xmlhttpRequest({
            method: method,
            url: url,
            headers: {
                "Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
            },

            onload: function(response){
                console.log(response);
                //var name=response.responseText;
                //name=JSON.parse(name);

            },
            onerror: function(response){
                console.log("请求失败");
            }
        });
    }
})();