function answerMatch(question) { const current = question ?? document.querySelector('.task-card[style]:not([style="display: none;"])') $('input[name=result]', '#q'+quest_id).val().split(';') .map(el => current.querySelector(`[value="${el}"]`)) .forEach(el => { el.checked = true; el.nextSibling.click(); }) current.querySelector('.q-next').click() } function answerSingle(question) { const current = question ?? document.querySelector('.task-card[style]:not([style="display: none;"])') const ans = current.querySelector(`[value="${$('input[name=result]', '#q'+quest_id).val()}"]`); ans.checked = true; ans.nextSibling.click() current.querySelector('.q-next').click() } function answerAll() { document.getElementsByClassName('q1')[0].click() const questions = [...document.getElementById('wrap').children]; questions.forEach(q => { if(q.querySelector('[name="a"]')) answerSingle(q); else answerMatch(q); }) }