自动答题

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

目前为 2022-06-08 提交的版本。查看 最新版本

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

(function() {
    var timer
    var questions = window.questions
    var prve = ''
    var alertAble = true
    let questAddress = window.questAddress
    let basePath = 'https://www.wizard101.com/quiz/trivia/game/'

    function createBtnGroup(){
        let container = document.createElement('div')
        container.style=`
            display:flex;
            flex-direction: column;
            width:270px;
            padding:20px 0;
            position:fixed;
            text-align:center;
            top:0;
            right:0;
            background:rgb(57 57 57 / 85%);
            z-index:1000;
            border-radius:10px;
            color:white;
        `
        let h22 = document.createElement('h1')
        h22.innerText = '导航(点击并跳转到新页面)'
        h22.style.color = 'white'
        h22.style.fontSize = '22px'
        container.append(h22)
        let h2 = document.createElement('h2')
        h2.innerText = 'Nav(click and go to new Page)'
        h2.style.color = 'white'
        container.append(h2)
        questAddress.forEach((element,idx) => {
            let btn = document.createElement('div')
            btn.style=`
                width:100%;
                position:relative;
                height:24px;
                line-height:24px;
                text-align:left;
                cursor:pointer;
                padding-left:15px;
            `
            btn.innerText = `${idx+1}、${element}`
            btn.onclick = ()=>{
                window.location.href = basePath + element
            }
            container.append(btn)
        });
        document.body.append(container)
    }
    createBtnGroup()
    // 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)
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址