Greasy Fork

Greasy Fork is available in English.

Gooboo辅助

循环学习、参加考试、使用装备

当前为 2023-12-06 提交的版本,查看 最新版本

// ==UserScript==
// @name         Gooboo辅助
// @license      MIT
// @namespace    http://tampermonkey.net/
// @homepage     http://greasyfork.icu/zh-CN/scripts/481441-gooboo辅助
// @version      1.3
// @description  循环学习、参加考试、使用装备
// @author       jasmineamber
// @match        https://gityxs.github.io/gooboo/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.io
// @require       https://cdn.jsdelivr.net/npm/[email protected]/bignumber.min.js
// @grant        GM_registerMenuCommand
// ==/UserScript==

(function() {
    'use strict';
    BigNumber.config({ EXPONENTIAL_AT: 1e+9 })
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }
    async function auto_calc() {
        let id
        let question = null
        id = setInterval(function() {
            let answer = ""
            let next_question = document.querySelector(".question-text")
            if (next_question == null) {
                clearInterval(id);
                return
            }
            if (question === next_question.innerText) {
                return
            }
            question = next_question.innerText

            let input = document.querySelector("#answer-input-math")
            input.value = ""
            input.dispatchEvent(new Event("input"))
            if(question.indexOf("^") > 0){
                const nums = question.split("^")
                answer = Math.pow(nums[0], nums[1])
            } else if (question.startsWith("√")) {
                answer = eval(question.replace("√", ""))
                answer = Math.sqrt((answer))
            } else if (question.indexOf("e") > 0) {
                let x = BigNumber(question.split(" ")[0]);
                let y = BigNumber(question.split(" ")[2]);
                if (question.indexOf(" + ") > 0) {
                    answer = x.plus(y).toString()
                } else {
                    answer = x.minus(y).toString()
                }
            } else {
                answer = eval(question)
            }
            input.value = answer
            input.dispatchEvent(new Event("input"))
            let btn = [...document.querySelectorAll(".v-btn__content")].find(item=>item.innerText === "答题")
            btn.click()
        }, 200)
    }
    function auto_writing() {
        let id
        id = setInterval(function() {
            let input = document.querySelector(".answer-input input")
            let text = ''
            let nodes = document.querySelector(".question-text .mx-2")
            if (nodes == null) {
                clearInterval(id);
                return
            }
            nodes = nodes.querySelectorAll("span")
            for (let i of nodes) {
                text += i.innerText
            }
            input.value = text
            input.dispatchEvent(new Event('input'))
        }, 200)
    }
    let id_study
    async function math(is_first=false) {
        clearInterval(id_study)
        let target = [...document.querySelectorAll(".v-card__title")].find(item => item.innerText === "数学")
        if (!target) {
            if (is_first) {
                alert("请解锁数学科目后再使用")
            }
            return
        }
        let btn_study = [...target.parentNode.querySelectorAll(".v-btn__content")].find(item => item.innerText === "学习")
        if (btn_study) {
            btn_study.click()
            await sleep(2000)
            auto_calc()
        }
        id_study = setInterval(math, 5000)
    }
    async function literature(is_first=false) {
        clearInterval(id_study)
        let target = [...document.querySelectorAll(".v-card__title")].find(item => item.innerText === "文学")
        if (!target) {
            if (is_first) {
                alert("请解锁文学科目后再使用")
            }
            return
        }
        let btn_study = [...target.parentNode.querySelectorAll(".v-btn__content")].find(item => item.innerText === "学习")
        if (btn_study) {
            btn_study.click()
            await sleep(2000)
            auto_writing()
        }
        id_study = setInterval(literature, 5000)
    }
    GM_registerMenuCommand("[学校]开始学习数学", async function() {
        await math(true)
    }, "1")
    GM_registerMenuCommand("[学校]开始学习文学", async function() {
        await literature(true)
    }, "2")
    GM_registerMenuCommand("[学校]停止学习", function() {
        clearInterval(id_study);
    }, "3")

    GM_registerMenuCommand("[学校]参加数学考试", async function() {
        let target = [...document.querySelectorAll(".v-card__title")].find(item => item.innerText === "数学")
        if (!target) {
            alert("请解锁数学科目后再使用")
            return
        }
        let id
        let btn_exam = [...target.parentNode.querySelectorAll(".v-btn__content")].find(item => item.innerText === "参加考试")
        if (btn_exam) {
            btn_exam.click()
            await sleep(2000)
            auto_calc()
        }
    }, "4")
    GM_registerMenuCommand("[学校]参加文学考试", async function() {
        let target = [...document.querySelectorAll(".v-card__title")].find(item => item.innerText === "文学")
        if (!target) {
            alert("请解锁文学科目后再使用")
            return
        }
        let id
        let btn_exam = [...target.parentNode.querySelectorAll(".v-btn__content")].find(item => item.innerText === "参加考试")
        if (btn_exam) {
            btn_exam.click()
            await sleep(2000)
            auto_writing()
        }
    }, "5")
    GM_registerMenuCommand("[部落]自动攻击", function() {
        let id
        id = setInterval(function() {
            let skill_bar = document.querySelector("html body div#app.v-application.game-app.v-application--is-ltr.theme--light.background-theme-default.css-shadow-2 div.v-application--wrap main.v-main div.v-main__wrap div div.row.no-gutters div.scroll-container-tab.col.col-6 div.ma-1 div.row.no-gutters div.col-sm-6.col-12 div.d-flex.flex-wrap.ma-1.mb-2.pa-1.v-card.v-sheet.theme--light");
            if (skill_bar == null) {
                clearInterval(id);
                return
            }
            let skills = skill_bar.querySelectorAll(".v-icon");
            [...skills].forEach(item => {
                item.click()
            })
        }, 1000)
    }, "a")
})();