Greasy Fork

Greasy Fork is available in English.

奥鹏在线作业助手

奥鹏在线答题小助手

当前为 2020-06-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         奥鹏在线作业助手
// @namespace    https://github.com/ousui/open-learn-helper
// @version      0.9.1
// @description  奥鹏在线答题小助手
// @author       shuai.w
// @match        https://learn.open.com.cn/StudentCenter/OnLineJob/*
// @grant        none
// ==/UserScript==

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

    function main() {
        if (document.getElementsByClassName('Opration-Btn-Box').length == 0) { return; };
        clearInterval(check);

        // 这里执行比较快,需要延迟执行
        setTimeout(crack_common, 3000);
        
        
    }

    function add_btn() {
        $('.Opration-Btn-Box').append('<hr />');
        add_btn('show', do_tags, '搜题');
        add_btn('clean', do_clean, '重做');
    }

    function add_btn(tag, func, text) {
        $('.Opration-Btn-Box').append(
            '<button class="same-margin relative Choosed-Item" x-btn-'+tag+'>'+text+'</button>'
        );

        $('.Opration-Btn-Box button[x-btn-'+tag+']')
            .on('click', func);
    }

    function do_clean() {
        $('.Choosed').click();
    }

     function do_tags() {

        $('.Subject-Title').each(function(i, e){
            var parent = $(e).parents('.Subject-Area');
            
            if (!!parent.attr('x-init')) {
                return;
            }

            parent.attr('x-init', true);
            
            var question = $(e).text();
            var equestion = encodeURIComponent(question);

            var query = $('<div>').css({
                'background': '#efefef',
                'margin-top': '-10px'
            });

            parent.find('.Subject-Title').after(query);
            get_forword_tag(query, 0, "https://www.shangxueba.com/ask/search.aspx?key="+ equestion, "上学吧");
            get_forword_tag(query, 1, "http://www.baidu.com/s?wd="+ equestion, "百度!");
            query.find('a[x-query-li]').css({
                'color': '#03b000',
                'margin': '3px 5px 3px 3px',
                'padding': '0px 5px',
                'font-weight': 800,
                'cursor': 'pointer',
                'font-size': 'larger',
                'padding': '0 8px'
            });
        });

         // fix_width();
    }

    function get_forword_tag(el, i, link, text) {
       var el_a = $('<a />').attr({
            'x-query-li': i,
            'href': link,
            'title': text,
            'target': '_blank'
        }).html(text);
        el.append(el_a);
    }

    function fix_width() {
        $('.blank-title td img').css('width', 'auto');
        $('.question-options li img').css('width', 'auto');
    }

    function request_monitoring() {
        $(document).ajaxComplete(
            function(event, xhr, settings) {

                if (settings.url.indexOf('OnlineJob/DoHomework') <= 0) {
                    return;
                }
                $('.qestitle').each(function(i, e){
                    var question = $(e).text();
                    var equestion = encodeURIComponent(question);
                    var td = $(e).attr('style', '');
                    td.parent().prepend('<td><a href="http://www.baidu.com/s?wd='+ question +'" target="_blank">Q</a></td>');
                    var height = td.height();

                    td.html('<textarea readonly style="width: 100%; border:0; font-weight:400;">'+question+'</textarea>').find('textarea').height(height);
                    // 太丑
                    // var squestion = question.replace(' )', ' ').replace('(', '').replace('。', '');
                    // td.parent().parent().append('<tr><td colspan="3"><input style="width: 100%; height:20px; font-size: 14px;font-weight:100;" value="' + squestion + '" /></td></tr>');
                });
            }
        );
    }

    // 破解常规限制:右键、 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');
    }
})();