自动答题

适用于某个场景下的自动答题

As of 2022-06-08. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         自动答题
// @namespace    http://tampermonkey.net/
// @version      0.3.7
// @description  适用于某个场景下的自动答题
// @author       蓝色灭火器
// @match        https://www.wizard101.com/quiz/trivia/game/*
// @icon         https://www.google.com/s2/favicons?domain=www.wizard101.com
// @grant        none
// @license      MIT
// @require      https://greatest.deepsurf.us/scripts/446167-quiz-answer/code/quiz_answer.js?version=1058841
// ==/UserScript==

(function() {
    var timer
    var questions = window.questions
    var prve = ''
    var alertAble = true
    // console.log(questions)
    // 找答案
    function findAnswer(){
        let quiz = document.getElementsByClassName('quizQuestion')
        let title = quiz.length > 0 ? quiz[0].innerText.trim() : ''
        let answerr = questions[title]
        // console.log(answerr)
        if(answerr){
            alertAble = true
            return answerr || ''
        }else{
            if(quiz.length === 0){
                // console.log('⭐坐稳了,准备开车⭐')
                return ''
            }
            if(alertAble){
                alertAble = false
                alert('⭐适用于wizard101题目(9个)和pirate101 Valencia题目(1个)⭐')
            }
            return ''
        }
    }
    // 选答案并提交
    function answer(answerVal){
        let quiz = document.getElementsByClassName('quizQuestion')
        let title = quiz.length > 0 ? quiz[0].innerText.trim() : ''
        if(prve === title){
            //题目没有提交完成
            return
        }
        if(answerVal === ''){
            // console.log('未找到答案...')
            return
        }
        let answerText = document.getElementsByClassName('answerText')
        let largecheckbox = document.getElementsByClassName('largecheckbox')
        for (let i = 0; i < answerText.length; i++) {
            let answerTextt = answerText[i]?.innerText.trim()
            let answerVall = answerVal.trim()
            // console.log(answerTextt,answerVall,answerTextt === answerVall)
            if(answerTextt === answerVall){
                console.log('⭐答案⭐')
                console.log(`♥${answerVall}♥`)
                // console.log(answerTextt)
                // console.log(answerVall)
                largecheckbox[i].classList.replace('largecheckbox','largecheckboxselected')
                setTimeout(()=>{
                    window.selectQuizAnswer(document.getElementsByClassName('largecheckboxselected')[0])
                    window.updateQuiz();
                },1500)
                let quiz = document.getElementsByClassName('quizQuestion')
                let title = quiz.length > 0 ? quiz[0].innerText.trim() : ''
                prve = title
            }
        }
    }
    timer = setInterval(function () {
        if(document.getElementsByClassName('quizQuestion').length === 0){
            return
        }
        console.log('⭐坐稳了,准备开车⭐')
        answer(findAnswer())
    },1000)
})();