Greasy Fork

Greasy Fork is available in English.

zyys_gdfda_org_auto_play_videos

用于[公需课] 刷课脚本

当前为 2022-01-25 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/439119/1012508/zyys_gdfda_org_auto_play_videos.js

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

window.onload = (function () {
    let htmlDivElementmask = document.createElement("div");
    htmlDivElementmask.innerHTML = '<div id="script_box"\n' +
        '     style="position: absolute;top: 40px;left: 200px;background-color: #e9d53c; z-index: 99999;width: auto;max-width: 700px;  height: auto;max-height: 500px; min-height: 100px; padding: 10px;">\n' +
        '    <div style="float: left;width: 380px"> 脚本运行状态:\n' +
        '        <div id="script_status" style="color:green; display: inline-block">无状态</div>\n' +
        '        <br>\n' +
        '        <br>\n' +
        '        <a href="javascript:;" onclick="function set_run_code(status) { window.localStorage.setItem(\'run_status\', status);location.reload();}set_run_code(\'start\')">运行脚本</a>\n' +
        '        <a href="javascript:;" onclick="function set_run_code(status) { window.localStorage.setItem(\'run_status\', status);location.reload();} set_run_code(\'stop\')">停止脚本</a>\n' +
        '    </div>\n' +
        '</div>'
    document.body.appendChild(htmlDivElementmask);

    function get_run() {
        if (get_run_code() === 'start') {
            $("#script_status").text('正在运行');
            return 1;
        } else {
            $("#script_status").text('已经停止');
            return -1;
        }
    }

    function get_run_code() {
        let storage = window.localStorage.getItem("run_status");
        if (!storage) {
            window.localStorage.setItem("run_status", "stop");
            storage = window.localStorage.getItem("run_status");
        }
        return storage;
    }

    if (location.href.search('https://zyys.gdfda.org/Home/User/enroll_les') > -1) {
        function select_a_video() {
            let video_list = $(".layui-table-main table tbody tr");
            for (let i = 0; i < video_list.length; i++) {
                let this_status = $($(video_list[i]).find('td')[3]).text();
                if (this_status.search('未学完') > -1) {
                    $($(video_list[i]).find('a')).click();
                    break;
                }
            }
        }


        let tag = setTimeout(function () {
            if (get_run() > 0) {
                clearTimeout(tag);
                select_a_video();//列表页面执行
            }

        }, 1000);


    } else if (location.href.search('zyys.gdfda.org/Home/User/study/id') > -1) {
        function ban_alert_confirm() {
            //注入失效 alert && confirm
            let script1 = document.createElement("script");
            script1.text = "var alert=function(){return true}; "
            document.body.appendChild(script1)
            let script2 = document.createElement("script")
            script2.text = "var confirm=function(){return true};"
            document.body.appendChild(script2)
        }

        function click_play_btn() {
            if ($($("#video div")[11]).text().search('/') > -1) {
                if ($("div[data-title='点击播放']").css("display") === "block") {
                    $("canvas")[0].click();
                }
            }
            if ($($("canvas")[8]).parent().css("display") === 'block') {
                $($("canvas")[8]).parent().click()
            }
        }

        function pop_question() {
            if ($("#dati").css("display") === "block") {
                $("#dati").css("display", "none");
            }
            click_play_btn();/*弹题暂停继续*/
        }

        ban_alert_confirm();
        let tag = setInterval(function () {
            click_play_btn();
            pop_question();
            if (get_run() < 0) {
                clearInterval(tag);
            }
        }, 1000)
    }
})();