Немає опису редагування
Мітка: Ручний відкіт
Немає опису редагування
Рядок 840: Рядок 840:
// =========================
// =========================
function createRandomButton() {
function createRandomButton() {
     if (document.getElementById('float-random-btn') || !document.body.classList.contains('skin-minerva')) {
    // Перевіряємо чи кнопка вже існує
     if (document.getElementById('float-random-btn')) {
        return;
    }
   
    // Перевіряємо чи це мобільна версія
    if (!document.body.classList.contains('skin-minerva')) {
         return;
         return;
     }
     }
Рядок 868: Рядок 874:
     `;
     `;
      
      
     btn.addEventListener('click', function() {
    // ПОКРАЩЕНИЙ ОБРОБНИК КЛІКУ
         window.location.href = '/w/index.php/Спеціальна:Випадкова_сторінка';
     btn.addEventListener('click', function(e) {
         e.preventDefault();
        e.stopPropagation();
       
        // Додаємо індикатор завантаження
        btn.innerHTML = '⏳ Завантаження...';
        btn.style.opacity = '0.7';
        btn.disabled = true;
       
        // Використовуємо window.location.replace для чистого переходу
        setTimeout(() => {
            window.location.replace('/w/index.php/Спеціальна:Випадкова_сторінка');
        }, 100);
     });
     });
      
      
     btn.addEventListener('mouseenter', function() {
     btn.addEventListener('mouseenter', function() {
         this.style.transform = 'scale(1.05)';
         if (!this.disabled) {
        this.style.boxShadow = '0 6px 20px rgba(0,0,0,0.4)';
            this.style.transform = 'scale(1.05)';
            this.style.boxShadow = '0 6px 20px rgba(0,0,0,0.4)';
        }
     });
     });
      
      
Рядок 883: Рядок 903:
      
      
     document.body.appendChild(btn);
     document.body.appendChild(btn);
    console.log('Кнопка Випадкова створена');
}
// АВТОМАТИЧНЕ ВІДНОВЛЕННЯ КНОПКИ ПІСЛЯ ПЕРЕХОДУ
// =========================
function restoreRandomButton() {
    // Перевіряємо чи ми на випадковій сторінці
    const isRandomPage = window.location.href.includes('Випадкова_сторінка') ||
                        window.location.href.includes('Special:Random');
   
    if (isRandomPage && document.body.classList.contains('skin-minerva')) {
        // Чекаємо повного завантаження сторінки
        setTimeout(() => {
            if (!document.getElementById('float-random-btn')) {
                createRandomButton();
            }
        }, 500);
    }
}
}