Greasy Fork

Greasy Fork is available in English.

奥鹏作业自动答题

打开考试自动筛选正确答案

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         奥鹏作业自动答题
// @version      0.0.1
// @description  打开考试自动筛选正确答案
// @author       DJX
// @match        https://learn.open.com.cn/StudentCenter/OnLineJob/*
// @run-at       document-idle
// @grant        none
// @namespace http://greasyfork.icu/users/398913
// ==/UserScript==

(function() {
    'use strict';
    // 页面执行完执行
    var check = setInterval(main, 250);
    var paperContent = [];

    function main() {
        if (window.require == null || window.jQuery == null) { return; };
        clearInterval(check);
        // 这里执行比较快,需要延迟执行
        setTimeout(crack_common, 3000);
        add_show_btn();
        request_monitoring();
    }

    function add_show_btn() {
        $('.score').append('<span class="marginr30" style="color: blue;" pp>SHOW GO</span>');
        $('.score span[pp]')
            .css({
                "cursor": "pointer",
                "color": "blue"
            })
            .on('click', show_quest);
    }


    function request_monitoring() {
        $(document).ajaxComplete(
            function(event, xhr, settings) {
                if (settings.url.indexOf('OnlineJob/DoHomework') <= 0) {
                    return;
                }
                var res = JSON.parse(xhr.responseText);
                if (res.status == 0) {
                    paperContent = res.data.TestPaperContent.Items;
                    show_quest();
                }
            }
        );
    }

    function show_quest() {
        $('.qestitle').each(function(i, e) {
            var choices = []
            var list = paperContent[i].Choices
            list.forEach(function(item) {
                if (item.IsCorrect) choices.push(item);
            });
            var question = $(e).text();
            var equestion = encodeURIComponent(question);
            var td = $(e).attr('style', '');
            choices.forEach(function(item) {
                td.parent().prepend('<td>选项:' + item.I1 + ' <->  值: ' + item.I2 + '</td>');
            })
            var height = td.height();
            td.html('<textarea readonly style="width: 100%; border:0; font-weight:400;">' + question + '</textarea>').find('textarea').height(height);
        });
    }

    // 破解常规限制:右键、 ctrl+c、 选中禁用
    function crack_common() {
        // 禁用右键
        document.oncontextmenu = function() {
            return true;
        }

        //禁用ctrl+c功能
        document.onkeydown = function() {
            if (event.ctrlKey && window.event.keyCode == 67) {
                return true;
            }
        }

        //禁用选中
        $(document).unbind('selectstart');
    }
})();