Mathspace Auto Solver

Automatically solves Mathspace questions and displays answers for user selection.

  1. // ==UserScript==
  2. // @name Mathspace Auto Solver
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Automatically solves Mathspace questions and displays answers for user selection.
  6. // @author You
  7. // @match *://*.mathspace.co/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var MathspaceSolver = {};
  15.  
  16. // Function to observe and extract the question
  17. MathspaceSolver.extractQuestion = function() {
  18. let questionElement = Sahin.waitForElement(".question-text", (element) => {
  19. let questionText = element.innerText.trim();
  20. console.log("Detected Question:", questionText);
  21. MathspaceSolver.repeatQuestion(questionText);
  22. });
  23. };
  24.  
  25. // Function to repeat the question in the answer box
  26. MathspaceSolver.repeatQuestion = function(question) {
  27. let answerBox = Sahin.waitForElement(".answer-input", (element) => {
  28. element.value = question;
  29. console.log("Repeated Question in Answer Box.");
  30. MathspaceSolver.solveQuestion(question);
  31. });
  32. };
  33.  
  34. // Function to solve the question (basic arithmetic operations)
  35. MathspaceSolver.solveQuestion = function(question) {
  36. try {
  37. let sanitizedQuestion = question.replace(/[^0-9+\-*/().]/g, ""); // Remove unwanted characters
  38. let answer = eval(sanitizedQuestion); // Solve the expression
  39. console.log("Solved Answer:", answer);
  40. MathspaceSolver.displayAnswer(answer);
  41. } catch (error) {
  42. console.log("Error solving the question:", error);
  43. }
  44. };
  45.  
  46. // Function to display the answer for user selection
  47. MathspaceSolver.displayAnswer = function(answer) {
  48. let answerContainer = Sahin.waitForElement(".answer-options", (element) => {
  49. let options = element.querySelectorAll(".option");
  50. options.forEach(option => {
  51. if (option.innerText.trim() == answer.toString()) {
  52. option.style.backgroundColor = "lightgreen"; // Highlight the correct answer
  53. }
  54. });
  55. console.log("Highlighted Correct Answer.");
  56. });
  57. };
  58.  
  59. // Start the script
  60. MathspaceSolver.init = function() {
  61. console.log("Mathspace Auto Solver Started...");
  62. MathspaceSolver.extractQuestion();
  63. };
  64.  
  65. Sahin.injectFunctionsToPage(MathspaceSolver);
  66. })();
  67.  
  68.  

QingJ © 2025

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