aq100

安全生产快速学习

当前为 2021-02-22 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         aq100
// @namespace    https://bjdc.100anquan.com/
// @version      0.7
// @description  安全生产快速学习
// @author       Shining
// @match        https://*.100anquan.com/*
// @match        http://*.100anquan.com/*
// @grant        unsafeWindow
// @grant        GM_log
// @grant        GM_xmlhttpRequest
// @grant        GM_setValue
// @grant        GM_getValue
// @connect      100anquan.com
// @run-at       document-end

// ==/使用网页自带的@require      https://libs.baidu.com/jquery/1.8.3/jquery.min.js
// ==/不require引入jquery时
// ==/不引入jquery,$设置的是原网页的jquery,如果设置为document-start时:因为提前注入,无法使用原网页的jquery,会提示找不到$
// ==/unsafeWindow 沙盒模式
// ==/document-end 文件加载后运行插件

// ==/UserScript==
var tooberUrl = unsafeWindow.location.href;
var $ = unsafeWindow.$;
GM_log(tooberUrl);

window.onload = function(){
    if(tooberUrl == "https://bjdc.100anquan.com/" || tooberUrl.indexOf("loginGeneralV2/") != -1){
        GM_log("进入首页");
        var logFun = unsafeWindow.GetLoginInfo;
        unsafeWindow.GetLoginInfo = function(){
            GM_log("登录事件");
            //----拦截方法1
            //可以logFun.toString()
            //替换字符串后,再见eval
            //var funStr = logFun.toString();
            //GM_log(funStr);
            //return unsafeWindow.eval(funStr);
            //----拦截方法2
            var accountName = $("#txtLogonUserCode").val();
            if(accountName != undefined && accountName != ""){
                var user = {
                    userName:accountName
                };
                GM_setValue("aq100_user",user);
            }
            GM_log(accountName);
            logFun();
        }
    }if(tooberUrl.indexOf("/course/courseEleView?") != -1){
        //因为@run-at document-start,在此设置页面加载完才运行
        GM_log("学习项");
        $("#Menu").before('<input id="hackBtn" style="background-color:yellow;font-size:20px" type="button" style="height:60px" onclick="hackTime()" value="【破解!直接学习完毕】">');
        var thisUrl = $("#Menu li a font[color='blue']");
        var nextUrl = thisUrl.parent().parent().next().find("a");
        var nextOnClick = undefined;
        if(nextUrl != undefined){
            nextOnClick = nextUrl.attr("onclick");
            if(nextOnClick != undefined){
                var str = nextUrl.text();
                $("#Menu").before('<div style="color:red;font-size:18px">破解完将自动翻到【下一页】<br/>【'+str+'】</div>');
            }else{
                $("#Menu").before('<div style="color:green;font-size:18px">破解完将自动返回【课程列表】<br/>【已到最后一页】</div>');
            }
        }
        unsafeWindow.hackTime = function(){
            var isFlash = false; //判断是否是flash控件播放
            var player = unsafeWindow.window.cc_js_Player;
            if(player == undefined){
               isFlash = true;
            }
            var time = 0;
            if(!isFlash){
                time = Math.round(unsafeWindow.window.cc_js_Player.getDuration());
            }else{
                time = Math.round(unsafeWindow.player.j2s_getDuration());
            }
            if(!isNaN(time) && time > 0){
                $("#stayInVideoTime").val(time);
                unsafeWindow.ajaxSendData();
                $("#hackBtn").val("已学完【"+time+"】秒");
                $("#hackBtn").css({'background-color':'green','color':'white'});
                $('#hackBtn').attr("disabled","disabled");
                if(nextOnClick != undefined){
                    unsafeWindow.eval(nextOnClick);
                }else{
                    unsafeWindow.returnForward();
                }
            }else{
                $("#hackBtn").val("破解失败【"+time+"】,请加载完视频再试");
                $("#hackBtn").css({'background-color':'red','color':'white'});
            }
            try
            {
                if(!isFlash){
                    unsafeWindow.window.cc_js_Player.pause();
                }else{
                    GM_log("FLASH NOT FUNCTION PAUSE();");
                }
            }
            catch(err)
            {
                GM_log(err);
            }
        }
    }else if(tooberUrl.indexOf("/directExam/examIndexAutoV2") != -1){
        //HTML directExam();
        //https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
        GM_log("考试");
        $("ul").each(function(){
            var ul = $(this);
            ul.find("li").each(function(){
                var attr = $(this).attr('onclick');
                if (typeof attr !== typeof undefined && attr !== false) {
                    if(attr.indexOf("chooseAnswer(") != -1){
                        //单选题chooseAnswer
                        //chooseAnswer('4','205549','0','0');  //最后一位是'1'是正确的
                        if(endWidth(attr,"'1');")){
                            $(this).append('&nbsp;&nbsp;<strong style="background-color:green;font-size:20px;color:white">&nbsp;【正确】&nbsp;</strong>');
                            $(this).click(); //自动点击正确
                        }
                    }else if(attr.indexOf("chooseJudgeAnswer(") != -1){
                        //判断题chooseJudgeAnswer
                        //chooseJudgeAnswer('T','332956','1')
                        //选择题以1结尾的应该选择正确,以0结尾的应该选择错误
                        if(endWidth(attr,"'1');")){
                            if ( ul.find(".hkmsg").length <= 0 ) { //避免重复添加
                                ul.append('<strong class="hkMsg" style="background-color:green;font-size:20px;color:white">&nbsp;请选择【正确】&nbsp;</strong>');
                                ul.find("li").eq(0).click(); //自动点击正确
                            }
                        }else{
                            if ( ul.find(".hkmsg").length <= 0) {
                                ul.append('<strong class="hkMsg" style="background-color:red;font-size:20px;color:white">&nbsp;请选择【错误】&nbsp;</strong>');
                                ul.find("li").eq(1).click(); //自动点击错误
                            }
                        }
                    }
                }
            });
        });

    }else if(tooberUrl.indexOf("/directExam/examInfoTestv2") != -1){
        //HTML directExam();
        //强行考试https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
        GM_log("强行考试");
        //也可以加button强引网址考试
        //onclick
        $(".tj_btn").before('<button style="background-color:yellow;font-size:20px" onclick="directExam();">强行考试</button>');
    }else if(tooberUrl.indexOf("/loginV2/userLogin") != -1){
        GM_log("跳过弱密码修改");
        if($("html").html().indexOf("鉴于您的密码过于简单") != -1){
             unsafeWindow.window.location.href = "https://bjdc.100anquan.com/index";
        }
    }else if(tooberUrl.indexOf("/course/personStudyPage/") != -1){
        //https://bjdc.100anquan.com/daxing/course/personStudyPage/3292/21762
        ////查看考试地址https://bjdc.100anquan.com/directExam/examInfoTestv2/2141?orgProjectId=4456
        GM_log("学习列表: " + GM_getValue("aq100_user").userName);
        //gotoExam('1987','4460')
        //var btn = $("input[onclick^='gotoExam(']");
        //if(btn.length >0){
            //判断jquery元素是否存在不能判断undefined需要判断length
            //var arr = btn.eq(0).attr("onclick").match(/\d+/g);
            //var url = "https://bjdc.100anquan.com/directExam/examInfoTestv2/" + arr[0] +"?orgProjectId=" + arr[1];
            //GM_log("hack " + url);
        //}
    }else if(tooberUrl.indexOf("/project/projectV2/") != -1){
        //https://bjdc.100anquan.com/project/projectV2/4010/Detai
        //破解后 https://bjdc.100anquan.com/person/personOrgSubjectList?orgProjectId=4515
        GM_log("课程列表");
        var regBtn = $("button[onclick^='registration(']").eq(0);
        if (regBtn != undefined){
            var onc = regBtn.attr("onclick");
            //registration('0.0','2020-02-25 10:59:40.0')
            if(onc != undefined && onc.indexOf("registration('0.0'") == -1){
                //收费的
                var substr = tooberUrl.match(/\/(\d+)\//);
                if(substr.length >= 1){
                    var num = substr[0].replace(/\//g,'');
                    var script = "javascrtpt:window.location.href='https://bjdc.100anquan.com/person/personOrgSubjectList?orgProjectId="+num+"'";
                    regBtn.parent().before('<br/><button class="btn-primary" style="margin-right:100px;" onclick="' + script + '">破解学习</button>');
                }
            }
        }
    }
    //else if(tooberUrl.indexOf("/course/personStudyPage/") != -1){
    //    // personStudyPage/4456/18881     orgProjectId/courseId
    //    // refreshPage(this,'59851','1');
    //    // goto https://bjdc.100anquan.com/daxing/course/courseEleView?elementId=59851&courseId=18881&wareIndex=1&orgProjectId=4456
    //    unsafeWindow.getItem = getItem //同名函数注入到前台
    //    $(".btn_ab").each(function(){
    //        var onc = $(this).attr("onclick");
    //        if(onc.indexOf("refreshPage") != -1){
    //            var arr = tooberUrl.split("\/");
    //            var orgProjectId = arr[arr.length - 2];
    //            var courseId = arr[arr.length - 1];
    //            var elementId = onc.split(",")[1].replace(/'/g,"");
    //            var wareIndex = onc.split(",")[2].replace(/'|\);/g,"");
    //            $(this).before('<input name="button2" type="button" class="btn_ab" id="button2" onclick="getItem('+elementId+','+courseId+','+wareIndex+','+orgProjectId+');" value="学习完毕">');
    //        }
    //    });
    //}
    function endWidth(str, target){
        var start = str.length-target.length;
        var arr = str.substr(start,target.length);
        if(arr == target){
            return true;
        }
        return false;
    }
    function getItem(elementId,courseId,wareIndex,orgProjectId){
        var url = "https://bjdc.100anquan.com/daxing/course/courseEleView?elementId=" + elementId + "&courseId=" + courseId + "&wareIndex=" + wareIndex + "&orgProjectId="+orgProjectId;
        get(url,function(html){
            GM_log(html);
        });
    }
    function get(url,call){
        GM_xmlhttpRequest({
            method: 'GET',
            url: url,
            headers: {},
            onload: function(responseDetails) {
                var html = responseDetails.responseText;
                call(html);
            }
        });
    }
}