Adds MathGPT-like interface to Mathspace
当前为
// ==UserScript==
// @name MathSpace MathGPT Integration
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds MathGPT-like interface to Mathspace
// @author PrimeMinisteModiji1111111111
// @match https://*.mathspace.co/*
// @grant GM_addStyle
// @grant GM_xmlhttpRequest
// @grant unsafeWindow
// @connect math-gpt.org
// ==/UserScript==
(function() {
'use strict';
// Add MathGPT Styles
GM_addStyle(`
.mathgpt-container {
position: fixed;
right: 20px;
top: 20px;
width: 400px;
background: white;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
z-index: 9999;
padding: 20px;
font-family: Arial, sans-serif;
}
.mathgpt-header {
display: flex;
align-items: center;
gap: 10px;
margin-bottom: 15px;
}
.mathgpt-logo {
width: 40px;
height: 40px;
}
.mathgpt-title {
font-size: 20px;
font-weight: bold;
color: #1a73e8;
}
.mathgpt-upload-area {
border: 2px dashed #ddd;
border-radius: 10px;
padding: 20px;
text-align: center;
margin-bottom: 15px;
cursor: pointer;
transition: all 0.3s;
}
.mathgpt-upload-area:hover {
border-color: #1a73e8;
background: #f8f9fa;
}
.mathgpt-input {
width: 100%;
min-height: 60px;
border: 1px solid #ddd;
border-radius: 10px;
padding: 10px;
margin-bottom: 10px;
resize: none;
}
.mathgpt-button {
background: #1a73e8;
color: white;
border: none;
padding: 8px 15px;
border-radius: 5px;
cursor: pointer;
font-size: 14px;
transition: background 0.3s;
}
.mathgpt-button:hover {
background: #1557b0;
}
.mathgpt-tools {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin-top: 15px;
}
.mathgpt-tool {
border: 1px solid #ddd;
border-radius: 15px;
padding: 8px;
text-align: center;
font-size: 12px;
cursor: pointer;
transition: all 0.3s;
}
.mathgpt-tool:hover {
background: #f8f9fa;
border-color: #1a73e8;
}
.mathgpt-solution {
margin-top: 15px;
padding: 15px;
background: #f8f9fa;
border-radius: 10px;
display: none;
}
`);
// Create MathGPT Interface
function createMathGPTInterface() {
const container = document.createElement('div');
container.className = 'mathgpt-container';
container.innerHTML = `
<div class="mathgpt-header">
<img src="https://math-gpt.org/icon.png" alt="MathGPT" class="mathgpt-logo">
<div class="mathgpt-title">MathGPT Solver</div>
</div>
<div class="mathgpt-upload-area">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7"/>
<line x1="16" x2="22" y1="5" y2="5"/>
<line x1="19" x2="19" y1="2" y2="8"/>
<circle cx="9" cy="9" r="2"/>
<path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/>
</svg>
<p>Drop your image here or click to upload</p>
</div>
<textarea class="mathgpt-input" placeholder="Type your math problem here..."></textarea>
<button class="mathgpt-button" id="solve-btn">Solve Problem</button>
<div class="mathgpt-tools">
<div class="mathgpt-tool">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1a73e8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect width="18" height="18" x="3" y="3" rx="2"/>
<path d="m9 8 6 4-6 4Z"/>
</svg>
Generate Video
</div>
<div class="mathgpt-tool">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1a73e8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M3 3v18h18"/>
<path d="m19 9-5 5-4-4-3 3"/>
</svg>
Graph
</div>
<div class="mathgpt-tool">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#1a73e8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 20h9"/>
<path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"/>
<path d="m15 5 3 3"/>
</svg>
Practice
</div>
</div>
<div class="mathgpt-solution" id="solution-area">
<h3>Solution:</h3>
<div id="solution-content"></div>
</div>
`;
document.body.appendChild(container);
// Add event listeners
const uploadArea = container.querySelector('.mathgpt-upload-area');
const solveButton = container.querySelector('#solve-btn');
const input = container.querySelector('.mathgpt-input');
uploadArea.addEventListener('click', () => {
const fileInput = document.createElement('input');
fileInput.type = 'file';
fileInput.accept = 'image/*';
fileInput.click();
fileInput.onchange = (e) => {
const file = e.target.files[0];
if (file) {
// Handle image upload
const reader = new FileReader();
reader.onload = (e) => {
// Here you would typically send the image to a server
alert('Image upload functionality coming soon!');
};
reader.readAsDataURL(file);
}
};
});
solveButton.addEventListener('click', () => {
const problem = input.value;
if (problem) {
const solutionArea = container.querySelector('.mathgpt-solution');
const solutionContent = container.querySelector('#solution-content');
solutionArea.style.display = 'block';
// Simulate solving (replace with actual API call)
solutionContent.innerHTML = `
<p><strong>Step 1:</strong> Analyzing problem...</p>
<p><strong>Step 2:</strong> Calculating solution...</p>
<p><strong>Result:</strong> ${evaluateMathExpression(problem)}</p>
`;
}
});
}
// Simple math expression evaluator
function evaluateMathExpression(expr) {
try {
return eval(expr.replace(/×/g, '*').replace(/÷/g, '/'));
} catch (e) {
return "Could not evaluate expression. Please check the format.";
}
}
// Initialize
if (window.location.hostname.includes('mathspace.co')) {
createMathGPTInterface();
}
})();