优课联盟|uooc小助手

优课联盟看视频,答题;题库非自有,用的超星coder_tq。

目前为 2021-04-06 提交的版本。查看 最新版本

// ==UserScript==
// @name         优课联盟|uooc小助手
// @namespace    http://tampermonkey.net/
// @version      1.1.2
// @description  优课联盟看视频,答题;题库非自有,用的超星coder_tq。
// @author       YR|亚日
// @match        http://www.uooc.net.cn/*
// @match        http://www.uooconline.com/*
// @icon         https://www.google.com/s2/favicons?domain=uooc.net.cn
// @grant        GM_xmlhttpRequest
//@connect        *
// @run-at       document-end
// @license      MIT
// ==/UserScript==
function opp() {
    $(".goback  ").prepend("<button id='key'>uook</button>");
    $("#key").hover(
        function () {
            $(this).prepend(kkk);
        },
        function () {
            $("#value").remove();
        }
    );
    var kkk = $(
        "<div id='value'><p>欢迎使用,菜鸟之作</p><a href='https://z3.ax1x.com/2021/04/05/cQcmZj.jpg'>鼓励   </a><a href=''>反馈:触日先森</a><p>提示:请等待5s、如遇卡顿请刷新</p><p>警告:有风险,切题库正确率无法保证</div>"
    )
}
//获取当前状态
function sleep(time) {
    return new Promise((resolve) => setTimeout(resolve, time));
}
var xxx = 0;
var sss = 0;

function sum() {
    function get(scope) {
        var i;
        var list;
        list = scope;
        for (i = 0; i < list.length; i++) {
            if (list[i].finished == 0) {
                break;
            }
        }
        return list[i]
    }
    //展开目录
    function open(scopel) {
        if (!scopel.hide) {} else {
            $("#" + scopel.id + ">div").click();

        }
    }
    var appElement = $(".rank-1").get(0);
    var $scope1 = angular.element(appElement).scope();
    var key = get($scope1.chapterList);
    open(key);
    var key1 = get(key.children);
    open(key1);
    if ($(".tag-source-name:contains('测验')")) {
        $(".tag-source-name:contains('测验')").parent().click();
    }
    return key1.unitSource;
}
//打开视频
function video(ttt) {
    var done = false
    $(".tag-source-name:contains('视频')").eq(ttt).parent().click();
    qt();
    let video = document.querySelector('#player_html5_api');
    video.playbackRate = 2;
    video.muted = true;
    video.play();

    function detect() {
        let quizLayer = document.querySelector('#quizLayer');
        if (quizLayer && quizLayer.style.display != 'none') {

            let source = JSON.parse(document.querySelector('div[uooc-video]').getAttribute('source'));
            let quizList = source.quiz;
            let quizIndex = 0;
            let quizQuestion = document.querySelector('.smallTest-view .ti-q-c').innerHTML;
            for (let i = 0; i < quizList.length; i++) {
                if (quizList[i].question == quizQuestion) {
                    quizIndex = i;
                    break;
                };
            };
            let quizAnswer = eval(quizList[quizIndex].answer);
            let quizOptions = quizLayer.querySelector('div.ti-alist');
            for (let ans of quizAnswer) {
                let labelIndex = ans.charCodeAt() - 'A'.charCodeAt();
                quizOptions.children[labelIndex].click();
            }; // end for
            quizLayer.querySelector('button').click();

        }; // end if
        if (video.ended) {
            done = true;
            link();
        }
        if (!done) {
            setTimeout(detect, 5000);
            if (video.paused) {
                video.play();
            } else {
                document.querySelectorAll('.layui-layer-shade, #quizLayer').forEach(e => e.style.display = 'none');
            };
        };
    }; // end if (video)

    detect();
}
//打开作业
function task() {
    var aaa = 0;
    var lement = $("iframe").contents().find(".ti-q-c");
    findanswer(lement[aaa]);

    function findanswer($ment) {
        var question = $($ment).text().replace(/^【.*?】\s*/, '').replace(/\s*(\d+\.\d+分)$/, '').replace(/[(]\s*[)]。$/,
            '').replace(/(\s*)。$/, '').replace(/[(]\s*[)]$/, '').replace(/(\s*)$/, '').replace(/。$/, '');


        GM_xmlhttpRequest({
            method: 'POST',
            url: 'http://cx.icodef.com/wyn-nb',
            headers: {
                'Content-type': 'application/x-www-form-urlencoded',
                'Authorization': {},
            },
            data: 'question=' + encodeURIComponent(question) + '&type=' + 0,
            timeout: 5000,
            onload: function (xhr) {
                if (xhr.status == 200) {
                    var obj = $.parseJSON(xhr.responseText) || {};
                    obj.answer = obj.data;
                    var qqq = $("iframe").contents().find(".ti-alist");
                    fillAnswer(qqq[aaa], obj);
                    aaa++;
                    sleep(500).then(() => {
                        findanswer(lement[aaa]);
                    })

                }
            }

        })
    }

    function filterImg(dom) {
        return $(dom).clone().find('img[src]').replaceWith(function () {
            return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
        }).end().find('iframe[src]').replaceWith(function () {
            return $('<p></p>').text('<iframe src="' + $(this).attr('src') + '"></irame>');
        }).end().text().trim();
    }

    function fillAnswer(li, obj) {
        var $li = $(li);
        var $input = $li.find(':radio, :checkbox'),
            str = String(obj.answer).toCDB() || new Date().toString(),
            data = str.split(/#|\x01|\|/),
            opt = obj.opt || str;
        $input.each(function (index) {
            if (this.value == 'A') {
                data.join().match(/(^|,)(正确|是|对|√|T|ri)(,|$)/) && this.click();
            } else if (this.value == 'B') {
                data.join().match(/(^|,)(错误|否|错|×|F|wr)(,|$)/) && this.click();
            } ;

                var tip = $li.find(".ti-a-c").eq(index).text().toCDB() || new Date().toString();
                Boolean($.inArray(tip, data) + 1 || (str.indexOf(tip) + 1)) == this.checked || this.click();

        }).each(function () {
            if (!/^A?B?C?D?E?F?G?$/.test(opt)) return false;
            Boolean(opt.match(this.value)) == this.checked || this.click();
        });

    }
    String.prototype.toCDB = function () {
        return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function (str) {
            return String.fromCharCode(str.charCodeAt(0) - 65248);
        }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
    };
}
//打开讨论
function discuss() {}

function qt() {
    $(".vjs-tech").off("mousemove", "**");
    $("html").off("mouseout", "**");
}

//链接函数
function link() {
    var resuit = sum();
    for (var mmm = 0; mmm < resuit.length; mmm++) {
        if (resuit[mmm].finished == 0 && resuit[mmm].content == null) {
            sss = mmm;
            break;
        } else if (resuit[mmm].content != null) {
            xxx++
        }
    }
    setTimeout("video(sss-xxx)", 1000);
}

function wait() {
    if (document.readyState == 'complete') {
        var s = window.location.href;
        var patt = /home\/learn\/index/i;
        var m = patt.test(s);
        if (m) {
            opp();
            link();
            if ($(".tag-source-name:contains('测验')")) {
                sleep(500);
                setTimeout(task, 5000);
            }

        }
    } else {
        setTimeout(wait, 500);
    }
};
wait();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址