|
|
| Рядок 102: |
Рядок 102: |
| applyFontSize(); | | applyFontSize(); |
| }); | | }); |
|
| |
|
| |
| // === Кнопка "Прослушать статью" ===
| |
| function addReadAloudButton() {
| |
| if (!document.querySelector('#mw-content-text')) return;
| |
|
| |
| // Создаём кнопку
| |
| var btn = document.createElement('button');
| |
| btn.textContent = "Прослушать статью";
| |
| btn.style.margin = "10px";
| |
| btn.style.padding = "5px 10px";
| |
| btn.style.cursor = "pointer";
| |
|
| |
| // Обработчик нажатия
| |
| btn.onclick = function() {
| |
| var content = document.querySelector('#mw-content-text').innerText;
| |
| if (!content) return;
| |
|
| |
| var utterance = new SpeechSynthesisUtterance(content);
| |
| // Настройки голоса
| |
| utterance.lang = 'ru-RU'; // Русский язык
| |
| utterance.rate = 1; // скорость
| |
| utterance.pitch = 1; // тон
| |
|
| |
| window.speechSynthesis.speak(utterance);
| |
| };
| |
|
| |
| // Добавляем кнопку в верхнюю часть страницы
| |
| var toolbar = document.querySelector('#p-views') || document.body;
| |
| toolbar.prepend(btn);
| |
| }
| |
|
| |
| // Ждём загрузки страницы
| |
| document.addEventListener('DOMContentLoaded', addReadAloudButton);
| |