function sleep(time) {
return new Promise(resolve => {
setTimeout(() => {
resolve(time);
}, Math.floor(time * 1000))
})
}
function checkElements(){
return new Promise((resolve, reject) => {
let interval = setInterval(() => {
var element = document.getElementsByClassName('answerQuestion')[0];
if(element != undefined) {
let title = document.getElementById("TimerHolder");
if(title == undefined) { return; }
function fillAnswer(question, data){
let id = question.id.substring(12);
let trs = question.getElementsByClassName('question-select-item');
if(trs.length === 0) {return;}
let mapping = getAnswerMapping(trs);
let answer = {};
let answerDiv = question.getElementsByClassName("question-item-right-answer")[0];
InsertAnswerUIElement(answerDiv, answer);
}
function InsertAnswerUIElement(controller, answer) {
let subController = controller.children;
for(let i = subController.length - 1; i >= 0; i--) {
controller.removeChild(subController);
}
let p = document.createElement('p');
p.style.color = answer.color;
p.innerText = answer.text;
controller.appendChild(p);
}
function getAnswerMapping(answers) {
let mapping = {};
answers.forEach(answer => {
let ori = answer.getAttribute('rel_label');
let map = answer.getElementsByClassName('question-select-item-label')[0].innerText;
mapping[ori] = map;
});