From 294c17f7f67db8eed8c4f559b9af84ae0b5eace5 Mon Sep 17 00:00:00 2001 From: MasterAkulon Date: Fri, 27 Mar 2026 11:25:44 +0300 Subject: [PATCH] feat: complete text quize --- script.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/script.js b/script.js index 71a4125..c2dad36 100644 --- a/script.js +++ b/script.js @@ -60,6 +60,42 @@ return false; } + function findTextQuiz() { + const quizzes = document.querySelectorAll('section.quiz_type_text'); + for (const quiz of quizzes) { + if (handledQuizzes.has(quiz)) continue; + if (quiz.classList.contains('quiz_answered')) { handledQuizzes.add(quiz); continue; } + const submitBtn = quiz.querySelector('button.quiz__submit'); + if (!submitBtn) { handledQuizzes.add(quiz); continue; } + if (quiz.offsetParent !== null) return quiz; + } + return null; + } + + async function handleTextQuiz(quiz) { + console.log('✏️ Текстовый квиз...'); + const textarea = quiz.querySelector('textarea.quiz__input-control'); + if (textarea) { + simulateTyping(textarea, 'не знаю'); + console.log('✓ Введён ответ'); + await sleep(400); + } + + const submitBtn = quiz.querySelector('button.quiz__submit'); + if (submitBtn && !submitBtn.disabled) { + submitBtn.click(); + console.log('✓ Нажата кнопка "Узнать ответ"'); + } else if (submitBtn) { + submitBtn.disabled = false; + submitBtn.click(); + console.log('✓ Принудительный клик "Узнать ответ"'); + } + + handledQuizzes.add(quiz); + await sleep(CLICK_DELAY); + return true; + } + function findCodingQuiz() { const quizzes = document.querySelectorAll('section.quiz_type_coding'); for (const quiz of quizzes) { @@ -271,6 +307,9 @@ const codingQuiz = findCodingQuiz(); if (codingQuiz) return { type: 'coding', element: codingQuiz }; + const textQuiz = findTextQuiz(); + if (textQuiz) return { type: 'text', element: textQuiz }; + const quiz = findQuizForm(); if (quiz) return { type: 'quiz', element: quiz }; @@ -299,6 +338,14 @@ continue; } + let textQuiz = findTextQuiz(); + if (textQuiz) { + scrollToElement(textQuiz); + await sleep(300); + await handleTextQuiz(textQuiz); + continue; + } + let quiz = findQuizForm(); if (quiz) { scrollToElement(quiz); @@ -338,6 +385,13 @@ continue; } + if (result.type === 'text') { + scrollToElement(result.element); + await sleep(300); + await handleTextQuiz(result.element); + continue; + } + if (result.type === 'quiz') { scrollToElement(result.element); await sleep(300);