Dantes (обсуждение | вклад) Нет описания правки |
Dantes (обсуждение | вклад) Нет описания правки |
||
| Строка 1: | Строка 1: | ||
document.addEventListener('DOMContentLoaded', function() { | |||
// 1. Обработка наведения мыши на ссылки в таблице | |||
document.querySelectorAll('.standard-link a').forEach(function(link) { | |||
link.addEventListener('mouseover', function() { | |||
link.closest('td').classList.add('highlight'); | |||
}); | |||
link.addEventListener('mouseout', function() { | |||
link.closest('td').classList.remove('highlight'); | |||
}); | |||
}); | |||
// 2. Добавление кнопки в тулбар | |||
const toolbar = document.getElementById('p-tb'); | |||
if (toolbar) { | |||
const newButton = document.createElement('li'); | |||
newButton.className = 'custom-button'; | |||
newButton.innerHTML = '<a href="/wiki/Специальная:Служебные_страницы">Кнопка</a>'; | |||
toolbar.appendChild(newButton); | |||
} | |||
// 3. Изменение цвета всех ссылок в основном контенте | |||
document.querySelectorAll('#mw-content-text a').forEach(function(link) { | |||
link.style.color = '#ff0000'; // Изменение цвета текста ссылок на красный | |||
}); | |||
// 4. Обработка нажатия на кнопку с ID 'myButton' | |||
const button = document.getElementById('myButton'); | |||
if (button) { | |||
button.addEventListener('click', function() { | |||
alert('Кнопка была нажата!'); | |||
}); | }); | ||
}); | } | ||
}); | |||
Версия от 07:55, 22 августа 2024
document.addEventListener('DOMContentLoaded', function() {
// 1. Обработка наведения мыши на ссылки в таблице
document.querySelectorAll('.standard-link a').forEach(function(link) {
link.addEventListener('mouseover', function() {
link.closest('td').classList.add('highlight');
});
link.addEventListener('mouseout', function() {
link.closest('td').classList.remove('highlight');
});
});
// 2. Добавление кнопки в тулбар
const toolbar = document.getElementById('p-tb');
if (toolbar) {
const newButton = document.createElement('li');
newButton.className = 'custom-button';
newButton.innerHTML = '<a href="/wiki/Специальная:Служебные_страницы">Кнопка</a>';
toolbar.appendChild(newButton);
}
// 3. Изменение цвета всех ссылок в основном контенте
document.querySelectorAll('#mw-content-text a').forEach(function(link) {
link.style.color = '#ff0000'; // Изменение цвета текста ссылок на красный
});
// 4. Обработка нажатия на кнопку с ID 'myButton'
const button = document.getElementById('myButton');
if (button) {
button.addEventListener('click', function() {
alert('Кнопка была нажата!');
});
}
});