Añade una guía paso a paso para resolver problemas matemáticos (no da respuestas). Útil para estudiar y aprender procedimientos.
// ==UserScript==
// @name Guía de resolución (educativa)
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Añade una guía paso a paso para resolver problemas matemáticos (no da respuestas). Útil para estudiar y aprender procedimientos.
// @author ChatGPT
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
/* --- UI: botón flotante --- */
const btn = document.createElement('button');
btn.textContent = 'Guía de resolución';
Object.assign(btn.style, {
position: 'fixed', right: '10px', bottom: '10px', zIndex: 999999,
padding: '8px 12px', borderRadius: '8px', border: 'none', cursor: 'pointer',
background: '#2b79d6', color: 'white', boxShadow: '0 2px 6px rgba(0,0,0,0.2)'
});
document.body.appendChild(btn);
/* --- Modal --- */
function createModal() {
const modal = document.createElement('div');
Object.assign(modal.style, {
position: 'fixed', left: 0, top: 0, width: '100%', height: '100%', zIndex: 1000000,
background: 'rgba(0,0,0,0.4)', display: 'flex', alignItems: 'center', justifyContent: 'center'
});
const card = document.createElement('div');
Object.assign(card.style, {
width: 'min(900px, 96%)', maxHeight: '90%', overflowY: 'auto', background: 'white', padding: '18px',
borderRadius: '10px', boxShadow: '0 8px 30px rgba(0,0,0,0.2)'
});
modal.appendChild(card);
const close = document.createElement('button');
close.textContent = 'Cerrar';
Object.assign(close.style, {float: 'right', marginBottom: '10px'});
close.onclick = () => modal.remove();
card.appendChild(close);
const title = document.createElement('h2');
title.textContent = 'Guía de resolución — pasos y recordatorios';
card.appendChild(title);
const inputLabel = document.createElement('p');
inputLabel.textContent = 'Selecciona el enunciado en la página y luego pulsa "Analizar", o pega el enunciado abajo:';
card.appendChild(inputLabel);
const textarea = document.createElement('textarea');
Object.assign(textarea.style, {width: '100%', height: '80px', marginBottom: '10px'});
card.appendChild(textarea);
const analyzeBtn = document.createElement('button');
analyzeBtn.textContent = 'Analizar';
Object.assign(analyzeBtn.style, {marginRight: '8px'});
card.appendChild(analyzeBtn);
const autoHint = document.createElement('div');
autoHint.style.marginTop = '12px';
card.appendChild(autoHint);
analyzeBtn.onclick = () => {
const text = (window.getSelection().toString().trim()) || textarea.value.trim();
if (!text) {
autoHint.innerHTML = 'Primero selecciona o pega el enunciado del problema.';
return;
}
const type = detectType(text);
autoHint.innerHTML = renderGuide(type, text);
};
return modal;
}
btn.onclick = () => {
const modal = createModal();
document.body.appendChild(modal);
};
/* --- Detección simple del tipo de problema --- */
function detectType(s) {
const t = s.toLowerCase();
if (/[0-9]\s*x\^?2|x\^2|quadratic|square|cuadr/i.test(t) || /x\s*\^?\s*2/.test(t)) return 'cuadratica';
if (/[0-9]\s*x|solve for x|ecuación|=/.test(t) && !/x\^2/.test(t)) return 'lineal';
if (/\barea\b|perimeter|área|perímetro|cm|m2|m²/.test(t)) return 'area';
if (/%|por ciento|percent|percentage/.test(t)) return 'porcentaje';
return 'general';
}
/* --- Render de pasos (NO CALCULA) --- */
function renderGuide(type, text) {
let html = `Enunciado detectado:
`;
html += '
';
html += '
';
html += '
';
return html;
}
function escapeHtml(str) {
return str.replace(/[&<>"']/g, function(m){ return ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[m]); });
}
})();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址