window.addEventListener("load", function () { const levelSelect = document.querySelectorAll("select")[1]; const outputBox = document.querySelector("textarea[aria-label='📝 Transcription & Correction']"); const historyContainer = document.querySelector("#history-output"); const savedLevel = localStorage.getItem("level"); if (savedLevel && levelSelect) levelSelect.value = savedLevel; // Crear botón para borrar historial const clearBtn = document.createElement("button"); clearBtn.textContent = "🗑️ Borrar historial"; clearBtn.style.marginTop = "10px"; clearBtn.style.padding = "5px 10px"; clearBtn.style.backgroundColor = "#ffdddd"; clearBtn.style.border = "1px solid #d33"; clearBtn.style.cursor = "pointer"; clearBtn.style.fontWeight = "bold"; // Insertar botón después del contenedor principal if (historyContainer && historyContainer.parentNode) { historyContainer.parentNode.insertBefore(clearBtn, historyContainer.nextSibling); } function mostrarCorrecciones(level) { const stored = JSON.parse(localStorage.getItem("corrections_by_level") || "{}"); const frases = stored[level] || []; if (outputBox) { const formatted = frases.map((c, i) => `#${i + 1}: ${c}`).join("\n"); outputBox.placeholder = frases.length ? `Last 3 corrected for level "${level}":\n${formatted}` : `No corrections yet for level "${level}".`; } if (historyContainer) { historyContainer.innerHTML = frases.length ? `