Mathspace Tutor Box

Adds a tutor box to Mathspace

目前為 2025-02-14 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Mathspace Tutor Box
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Adds a tutor box to Mathspace
// @author       Your Name
// @match        *://*.mathspace.co/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function createTutorBox() {
        // Remove existing box if it already exists
        let existingBox = document.getElementById("mathspace-tutor");
        if (existingBox) existingBox.remove();

        // Create the floating box
        let tutorBox = document.createElement("div");
        tutorBox.id = "mathspace-tutor";
        tutorBox.style.position = "fixed";
        tutorBox.style.bottom = "20px";
        tutorBox.style.right = "20px";
        tutorBox.style.background = "#0073e6";
        tutorBox.style.color = "white";
        tutorBox.style.padding = "15px";
        tutorBox.style.borderRadius = "8px";
        tutorBox.style.boxShadow = "0px 0px 10px rgba(0,0,0,0.2)";
        tutorBox.style.cursor = "pointer";
        tutorBox.style.zIndex = "1000";
        tutorBox.style.fontSize = "16px";
        tutorBox.style.fontWeight = "bold";
        tutorBox.innerText = "Mathematical Tutor";

        // Add click event
        tutorBox.addEventListener("click", function() {
            tutorBox.innerText = "Analysing...";
            setTimeout(() => {
                tutorBox.innerText = "Analysing the Question...";
                setTimeout(() => {
                    tutorBox.innerText = "Fetching tools...";
                    setTimeout(() => {
                        tutorBox.innerText = "Did you know the creator was a 13-year-old kid?";
                        setTimeout(() => {
                            captureProblem(tutorBox); // Move to the next step
                        }, 2000);
                    }, 2000);
                }, 2000);
            }, 2000);
        });

        // Add to the page
        document.body.appendChild(tutorBox);
    }

    function captureProblem(tutorBox) {
        let problemText = getMathProblem();

        // If problem isn't found, immediately ask for manual input
        if (problemText === "Problem not found!") {
            manualProblemInput(tutorBox);
            return;
        }

        // Otherwise, ask if the detected problem is correct
        tutorBox.style.width = "300px";
        tutorBox.style.height = "auto";
        tutorBox.style.padding = "20px";
        tutorBox.innerHTML = `
            <b>Is this the correct problem?</b><br><br>
            <i>${problemText}</i><br><br>
            <button id="confirmProblem" style="margin-right: 10px; background: green; color: white; padding: 5px; border: none; cursor: pointer;">Yes, it is right</button>
            <button id="editProblem" style="background: red; color: white; padding: 5px; border: none; cursor: pointer;">No, let me type it in</button>
            <div id="manualInput" style="margin-top: 10px; display: none;">
                <input type="text" id="manualProblem" style="width: 90%;" placeholder="Type the problem here...">
                <button id="submitProblem" style="background: blue; color: white; padding: 5px; border: none; cursor: pointer;">Submit</button>
            </div>
        `;

        document.getElementById("confirmProblem").addEventListener("click", () => {
            tutorBox.innerText = "Question received!";
            setTimeout(() => {
                tutorBox.innerText = "Analysing and solving...";
            }, 2000);
        });

        document.getElementById("editProblem").addEventListener("click", () => {
            document.getElementById("manualInput").style.display = "block";
        });

        document.getElementById("submitProblem").addEventListener("click", () => {
            let userInput = document.getElementById("manualProblem").value;
            if (userInput.trim() === "") return; // Prevent empty input

            tutorBox.innerHTML = `<b>Question received:</b> <br><br> <i>${userInput}</i> <br><br> Analysing and solving...`;
        });
    }

    function manualProblemInput(tutorBox) {
        tutorBox.style.width = "300px";
        tutorBox.style.height = "auto";
        tutorBox.style.padding = "20px";
        tutorBox.innerHTML = `
            <b>Type the problem:</b><br><br>
            <input type="text" id="manualProblem" style="width: 90%;" placeholder="Type the problem here...">
            <button id="submitProblem" style="background: blue; color: white; padding: 5px; border: none; cursor: pointer;">Submit</button>
        `;

        document.getElementById("submitProblem").addEventListener("click", () => {
            let userInput = document.getElementById("manualProblem").value;
            if (userInput.trim() === "") return; // Prevent empty input

            tutorBox.innerHTML = `<b>Question received:</b> <br><br> <i>${userInput}</i> <br><br> Analysing and solving...`;
        });
    }

    function getMathProblem() {
        let problemElement = document.querySelector('[data-testid="question-content"]'); // Change this selector if needed
        return problemElement ? problemElement.innerText.trim() : "Problem not found!";
    }

    // Ensure the script runs when the page is fully loaded
    window.addEventListener("load", createTutorBox);
})();



QingJ © 2025

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