GDPR 188bet.astute-elearning.com

try to take over the world!

当前为 2020-10-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         GDPR 188bet.astute-elearning.com
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://188bet.astute-elearning.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://greasyfork.org/scripts/5392-waitforkeyelements/code/WaitForKeyElements.js?version=115012
// ==/UserScript==

(function() {
    //start按鈕出現時,就按下所有的continue button
   waitForKeyElements ("div:contains('Test Your Knowledge')", clickContinueButton);
    getAnswerList();

})();

//取得答案列表
function getAnswerList(){
    var match =  /(.*)index\.html/.exec(window.location.href);
    var answerJson = match[1]+'course/en/components.json';
    $.getJSON( answerJson , function( data ) {
        window.answerComponent = data.filter(function (obj){
            return obj._component==='mcq' || obj._component==='matching';
        });
        waitForKeyElements('.mcq-component,.matching-component',displayAnswer);
    });
}

function displayAnswer(){
         $(window.answerComponent).each(function() {
             var question = this;
             //顯示radio button,input的答案
             if(question._component ==="mcq"){
               displayInputAnswer(question);
             }
             else{
                 //顯示下拉選單的答案
                 displayDropDownAnswer(question);
             }
       });
}

function displayInputAnswer(question){
             var answer = question._items.filter(function (obj){
                 return obj._shouldBeSelected===true;
             });
             $(answer).each(function(){
                 $('div[data-adapt-id="'+question._id+'"]').find(".mcq-item-inner:contains('"+this.text+"')").css("background-color","green");
             });

}

function displayDropDownAnswer(questions){
            //dropdown的questionComponent,底下會有好幾個question,再裡面才是dropdown的選項
            $(questions._items).each(function(){
                var question = this
                var dropdownTitle = question.text;

                $(question).each(function(){
                    var dropdownSelection = this._options;
                    var correctSelection = dropdownSelection.filter(function (obj){
                        return obj._isCorrect===true;
                    });
                    console.log(questions._id + "  dropDownTitle:"+ dropdownTitle+"  answer:"+correctSelection[0].text);
                    $('div[data-adapt-id="'+questions._id+'"]').find(".matching-item-title:contains('"+dropdownTitle+"')").next().find("li[text='"+correctSelection[0].text+"']").css("background-color","green");
                });

             });
}

function clickContinueButton(){
    $("button:contains('Continue')").click();
    $("button:contains('Continue')").attr("disabled",true);
}