aq100

安全生产快速学习

目前為 2021-02-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         aq100
// @namespace    https://bjdc.100anquan.com/
// @version      0.1
// @description  安全生产快速学习
// @author       Shining
// @match        https://*.100anquan.com/*
// @match        http://*.100anquan.com/*
// @grant        unsafeWindow
// @grant        GM_log
// @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.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="【破解!直接学习完毕】">');
        unsafeWindow.hackTime = function(){
            unsafeWindow.window.cc_js_Player.pause();
            var time = Math.round(unsafeWindow.window.cc_js_Player.getDuration());
            if(!isNaN(time)){
                $("#stayInVideoTime").val(time);
                unsafeWindow.ajaxSendData();
                $("#hackBtn").val("已学完【"+time+"】秒");
                $("#hackBtn").css({'background-color':'green','color':'white'});
                $('#hackBtn').attr("disabled","disabled");
            }else{
                $("#hackBtn").val("破解失败【"+time+"】,请加载完视频再试");
                $("#hackBtn").css({'background-color':'red','color':'white'});
            }
        }
    }else if(tooberUrl.indexOf("/directExam/examIndexAutoV2") != -1){
        //HTML directExam();
        //https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
        GM_log("考试");
        //onclick
        $("li").each(function(){
            var attr = $(this).attr('onclick');
            if (typeof attr !== typeof undefined && attr !== false) {
                //chooseAnswer('4','205549','0','0');  //最后一位是'1'是正确的
                if(endWidth(attr,"'1');")){
                    $(this).append('&nbsp;&nbsp;<strong style="background-color:red;font-size:20px;color:white">&nbsp;✔&nbsp;</strong>');
                }
            }
        });
    }else if(tooberUrl.indexOf("/directExam/examInfoTestv2") != -1){
        //HTML directExam();
        //https://bjdc.100anquan.com/directExam/freePracticeV2/2141/4456/stochastic
        GM_log("强行考试");
        //onclick
        $(".tj_btn").before('<button style="background-color:yellow;font-size:20px" onclick="directExam();">强行考试</button>');
    }
    function endWidth(str, target){
        var start = str.length-target.length;
        var arr = str.substr(start,target.length);
        if(arr == target){
            return true;
        }
        return false;
    }
}