Mathspace Tutor Box

Adds a tutor box to Mathspace

目前为 2025-02-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Mathspace Tutor Box
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description Adds a tutor box to Mathspace
  6. // @author Your Name
  7. // @match *://*.mathspace.co/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function createTutorBox() {
  15. // Remove existing box if it already exists
  16. let existingBox = document.getElementById("mathspace-tutor");
  17. if (existingBox) existingBox.remove();
  18.  
  19. // Create the floating box
  20. let tutorBox = document.createElement("div");
  21. tutorBox.id = "mathspace-tutor";
  22. tutorBox.style.position = "fixed";
  23. tutorBox.style.bottom = "20px";
  24. tutorBox.style.right = "20px";
  25. tutorBox.style.background = "#0073e6";
  26. tutorBox.style.color = "white";
  27. tutorBox.style.padding = "15px";
  28. tutorBox.style.borderRadius = "8px";
  29. tutorBox.style.boxShadow = "0px 0px 10px rgba(0,0,0,0.2)";
  30. tutorBox.style.cursor = "pointer";
  31. tutorBox.style.zIndex = "1000";
  32. tutorBox.style.fontSize = "16px";
  33. tutorBox.style.fontWeight = "bold";
  34. tutorBox.innerText = "Mathematical Tutor";
  35.  
  36. // Add click event
  37. tutorBox.addEventListener("click", function() {
  38. tutorBox.innerText = "Analysing...";
  39. setTimeout(() => {
  40. tutorBox.innerText = "Analysing the Question...";
  41. setTimeout(() => {
  42. tutorBox.innerText = "Fetching tools...";
  43. setTimeout(() => {
  44. tutorBox.innerText = "Did you know the creator was a 13-year-old kid?";
  45. setTimeout(() => {
  46. captureProblem(tutorBox); // Move to the next step
  47. }, 2000);
  48. }, 2000);
  49. }, 2000);
  50. }, 2000);
  51. });
  52.  
  53. // Add to the page
  54. document.body.appendChild(tutorBox);
  55. }
  56.  
  57. function captureProblem(tutorBox) {
  58. let problemText = getMathProblem();
  59.  
  60. // If problem isn't found, immediately ask for manual input
  61. if (problemText === "Problem not found!") {
  62. manualProblemInput(tutorBox);
  63. return;
  64. }
  65.  
  66. // Otherwise, ask if the detected problem is correct
  67. tutorBox.style.width = "300px";
  68. tutorBox.style.height = "auto";
  69. tutorBox.style.padding = "20px";
  70. tutorBox.innerHTML = `
  71. <b>Is this the correct problem?</b><br><br>
  72. <i>${problemText}</i><br><br>
  73. <button id="confirmProblem" style="margin-right: 10px; background: green; color: white; padding: 5px; border: none; cursor: pointer;">Yes, it is right</button>
  74. <button id="editProblem" style="background: red; color: white; padding: 5px; border: none; cursor: pointer;">No, let me type it in</button>
  75. <div id="manualInput" style="margin-top: 10px; display: none;">
  76. <input type="text" id="manualProblem" style="width: 90%;" placeholder="Type the problem here...">
  77. <button id="submitProblem" style="background: blue; color: white; padding: 5px; border: none; cursor: pointer;">Submit</button>
  78. </div>
  79. `;
  80.  
  81. document.getElementById("confirmProblem").addEventListener("click", () => {
  82. tutorBox.innerText = "Question received!";
  83. setTimeout(() => {
  84. tutorBox.innerText = "Analysing and solving...";
  85. }, 2000);
  86. });
  87.  
  88. document.getElementById("editProblem").addEventListener("click", () => {
  89. document.getElementById("manualInput").style.display = "block";
  90. });
  91.  
  92. document.getElementById("submitProblem").addEventListener("click", () => {
  93. let userInput = document.getElementById("manualProblem").value;
  94. if (userInput.trim() === "") return; // Prevent empty input
  95.  
  96. tutorBox.innerHTML = `<b>Question received:</b> <br><br> <i>${userInput}</i> <br><br> Analysing and solving...`;
  97. });
  98. }
  99.  
  100. function manualProblemInput(tutorBox) {
  101. tutorBox.style.width = "300px";
  102. tutorBox.style.height = "auto";
  103. tutorBox.style.padding = "20px";
  104. tutorBox.innerHTML = `
  105. <b>Type the problem:</b><br><br>
  106. <input type="text" id="manualProblem" style="width: 90%;" placeholder="Type the problem here...">
  107. <button id="submitProblem" style="background: blue; color: white; padding: 5px; border: none; cursor: pointer;">Submit</button>
  108. `;
  109.  
  110. document.getElementById("submitProblem").addEventListener("click", () => {
  111. let userInput = document.getElementById("manualProblem").value;
  112. if (userInput.trim() === "") return; // Prevent empty input
  113.  
  114. tutorBox.innerHTML = `<b>Question received:</b> <br><br> <i>${userInput}</i> <br><br> Analysing and solving...`;
  115. });
  116. }
  117.  
  118. function getMathProblem() {
  119. let problemElement = document.querySelector('[data-testid="question-content"]'); // Change this selector if needed
  120. return problemElement ? problemElement.innerText.trim() : "Problem not found!";
  121. }
  122.  
  123. // Ensure the script runs when the page is fully loaded
  124. window.addEventListener("load", createTutorBox);
  125. })();
  126.  
  127.  
  128.  

QingJ © 2025

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