Greasy Fork

Greasy Fork is available in English.

crack_gooboo

try to crack gooboo

当前为 2024-05-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         crack_gooboo
// @namespace    http://tampermonkey.net/
// @version      0.12
// @description  try to crack gooboo
// @author       niushuai233
// @match        https://gityxs.github.io/gooboo/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=github.io
// @require      https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var answering = false;
    var ansInterval;
    var ansSec = 0;

    $(".v-toolbar__content").prepend('<button id="answerME" >开始答题</button>');

    $("#answerME").click(function() {
        if (answering) {
            // 终止答题
            stopAnswer();
        } else {
            // 开启答题
            startAnswer();
        }
    });

    function startAnswer() {
        // 开启答题
        answering = true;

        // 判定多少秒后停止
        //ansSec = prompt("需要多少秒");

        setTimeout(stopAnswer, 30 * 1000)

        $("#answerME").html("终止答题");
        ansInterval = setInterval(answerOnce, 1000);
    }

    function stopAnswer() {
        // 终止答题
        answering = false;
        clearInterval(ansInterval);
        $("#answerME").html("开始答题");
    }

    function answerOnce() {
        // 获取答案
        var ansElem = $("#answer-input-math");
        if (!!!ansElem) {
            stopAnswer();
            return;
        }
        var htm = $(".question-text").html();
        var ansVal;
        if (htm.startsWith("√")) {
            ansVal = Math.sqrt(htm.replace("√",""));
            $(ansElem[0]).val(ansVal);
        } else {
            ansVal = eval(htm);
            $(ansElem[0]).val(ansVal);
        }

        var event = new InputEvent('input', {
            'bubbles': true,
            'cancelable': true
        });
        ansElem[0].dispatchEvent(event);

        // 提交答案
        var btnElem = $(".ma-1.v-btn.v-btn--is-elevated");
        $(btnElem[0]).click();
    }

})();