onlinedu自动播放

自动点击播放器元素以继续播放

目前为 2020-12-25 提交的版本。查看 最新版本

// ==UserScript==
// @name         onlinedu自动播放
// @namespace    c-h.cc
// @version      0.5.1
// @description  自动点击播放器元素以继续播放
// @author       JKRaks
// @match        www.onlinedu.org.cn
// @include      http://www.onlinedu.org.cn/*
// @include      https://www.onlinedu.org.cn/*
// @require      http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_setClipboard
// @grant        GM_info
// @grant        GM_xmlhttpRequest
// @grant        GM.getValue
// @grant        GM.setValue
// @grant        GM.setClipboard
// @grant        GM.info
// @grant        GM.xmlHttpRequest
// ==/UserScript==

(function() {
    $("head").append('<style>#ddiv{border-radius:10px;border:1px solid black;width:220px;height:400px;overflow:auto;position:fixed;left:0;top:200px;background:white} #ddiv a:hover.thin {border-color: transparent;}#ddiv a:hover.alt {background: red;}#ddiv a:hover.stroke {background-color: rgba(52, 221, 135, 0.08);color: #60e4a1;}#ddiv a.darkstroke {border-color: #343850;}#ddiv a.thin {border-width:1px;}#ddiv a.alt {border-color: #575c81;}#ddiv a.stroke {border: 2px solid #34dd87;color: #34dd87;}#ddiv a.pill {border-radius: 24px;}#ddiv a:hover, .btn:focus, .btn.focus {color: white;text-decoration: none;}#ddiv a {line-height: 1em;font-family: arial, sans-serif;font-size: 14px;font-weight: bold;color: #9c26b0;border:2px solid transparent;margin: 0 10px 10px 0;padding: 6px 14px;box-sizing: border-box;display: inline-block;text-align: center;vertical-align: middle;touch-action: manipulation;cursor: pointer;width: auto;white-space: nowrap;-webkit-transition: all 0.3s ease-in-out;-moz-transition: all 0.3s ease-in-out;-o-transition: all 0.3s ease-in-out;transition: all 0.3s ease-in-out;}#ddiv a:focus {outline: -webkit-focus-ring-color auto 1px;}</style>')
    $('body').append('<div id="ddiv" style=""><a style="background:#feeeed;margin:3px;border-radius:10px" href="javascript:" id="closeDivBtn">关闭</a><a style="background:#feeeed;margin:3px;border-radius:10px" href="javascript:" id="clearDivBtn">清空</a><ul id="uul" style="list-style:\'✔\'"><li id="startLi">已启动</li></ul></div>')
    var loadTime;

    try{
        loadTime = GM_getValue('loadTime',3000)
    }
    catch(err){
        GM_setValue('loadTime',3000)
    }

    setTimeout(function(){
        var $Lst=$(".el-progress__text")
        for(var i=0;i<$Lst.length;i++){
            if($Lst.eq(i).text()!="100%"){
                $Lst.eq(i).parent().parent().parent().parent().prev().find("h3").click()
                $Lst.eq(i).parent().parent().click()
                $Lst.eq(i).click()
                return;
            }
        }
    },loadTime);

    $("#setTime").click(function(){
        setLoadTime()
    })

    function updateLoadTime(){
        var Tm = $("#txtLoadTime").val();
        if (!(/(^[1-9]\d*$)/.test(Tm))) {
      alert('输入的不是正整数');
      return false;
    }
        GM_setValue("loadTime",Tm)
    }

    setInterval(function(){
        try{
            var vdo =$('video').get(0)
            var State = vdo.paused
            if(State){
                ck()
            }
        }
        catch(err){}
    },300)

    function ck(){
        $(".dplayer-video-wrap").click()
        $("#uul li:eq(0)").before('<li>'+getNow()+'重新播放</li>')
    }

    function getNow() {
        var myDate = new Date();
        var month=myDate.getMonth()+1;
        var date=myDate.getDate();
        var h=myDate.getHours();
        var m=myDate.getMinutes();
        var s=myDate.getSeconds();
        var now = month+'/'+date+' '+h+':'+m+':'+s;
        return now
    }

    $("#closeDivBtn").click(function(){
        $("#ddiv").remove()
    })
    $("#clearDivBtn").click(function(){
        $("#uul li :not(:last)").remove()
    })
})();