GDPR 188bet.astute-elearning.com

try to take over the world!

目前為 2020-10-28 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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);
}