Открыть меню
Переключить меню настроек
Открыть персональное меню
Вы не представились системе
Ваш IP-адрес будет виден всем, если вы внесёте какие-либо изменения.

MediaWiki:Test.js: различия между версиями

Страница интерфейса MediaWiki
Нет описания правки
Метка: отменено
Нет описания правки
 
(не показаны 23 промежуточные версии этого же участника)
Строка 1: Строка 1:
if (mw.config.get('wgPageName') === 'Участник:Dantes') {
(function() {  
 
     if (typeof mw === 'undefined' || !window.document) return;  
     // ===== CSS через JS =====
      
    var style = document.createElement('style');
     function initCollapse() {  
     style.type = 'text/css';
         var headings = document.querySelectorAll('.chem-heading');  
     style.textContent = ''
        var hi = 0;  
        + 'body { margin:0; padding:0; overflow:hidden; background-color:black; }'
        var len = headings.length;  
         + '.chaos-text { position:fixed; top:50%; left:50%; transform:translate(-50%,-50%); font-size:10vw; font-weight:900; text-align:center; z-index:1000; text-shadow:0 0 20px #ffff00, 0 0 30px #ff00ff; }'
        for (; hi < len; hi++) {
        + '.emoji, .sprite { position:absolute; pointer-events:none; user-select:none; }';
            (function(node) {  
    document.head.appendChild(style);
                if (node.getAttribute('data-chem-attached')) return;  
 
                node.setAttribute('data-chem-attached', '1');  
    // ===== Переменные =====
                node.style.cursor = 'pointer';  
    var colors = ['#ff0000','#00ff00','#0000ff','#ffff00','#ff00ff','#00ffff','#ffffff','#ff8000'];
                node.addEventListener('click', function() {
    var emojis = ['💥','🔥','🎉','👾','💀','🤡','👻','🌈','🚀','💩','🍕','🦄','😱','🙀','💫','⭐','🌀'];
                    var kind = node.getAttribute('data-kind') || '';  
 
                    var wrapper = findWrapper(node, kind);  
    // ===== HTML элемент =====
                    if (!wrapper) return;  
    var chaosText = document.createElement('div');
                    var btn = node.querySelector('.collapse-btn');  
    chaosText.className = 'chaos-text';
                   
    chaosText.textContent = 'ХАОС!';
                    if (wrapper.classList.contains('collapsed')) {  
    document.body.appendChild(chaosText);
                        wrapper.classList.remove('collapsed');  
 
                        wrapper.classList.add('expanded');  
    // ===== Вспомогательная функция =====
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px';  
    function randomItem(arr) {
                        if (btn) btn.textContent = 'свернуть';  
        return arr[Math.floor(Math.random() * arr.length)];
                        var cleanup = function() {  
    }
                            wrapper.style.maxHeight = '';  
 
                            wrapper.removeEventListener('transitionend', cleanup);  
    // ===== Создание эмодзи =====
                        };  
    function createEmojiSprite() {
                        wrapper.addEventListener('transitionend', cleanup);  
        var emoji = document.createElement('div');
                    } else {  
        emoji.className = 'emoji';
                        var currentHeight = wrapper.scrollHeight;  
        emoji.textContent = randomItem(emojis);
                        wrapper.style.maxHeight = currentHeight + 'px';  
        emoji.style.fontSize = (Math.random() * 60 + 20) + 'px';
                        wrapper.offsetHeight;
        emoji.style.color = randomItem(colors);
                        wrapper.classList.remove('expanded');  
        emoji.style.left = (Math.random() * window.innerWidth) + 'px';
                        wrapper.classList.add('collapsed');  
        emoji.style.top = (Math.random() * window.innerHeight) + 'px';
                        wrapper.style.maxHeight = '0px';  
        document.body.appendChild(emoji);
                        if (btn) btn.textContent = 'развернуть';  
 
                    }
        var x = parseFloat(emoji.style.left);
                });  
        var y = parseFloat(emoji.style.top);
            })(headings[hi]);  
        var xSpeed = (Math.random()-0.5)*10;
        }
        var ySpeed = (Math.random()-0.5)*10;
    }
        var rotation = 0;
   
        var rotationSpeed = (Math.random()-0.5)*20;
    function findWrapper(node, kind) {
 
         var parent = node.parentNode;  
        function move() {
         if (!parent) return null;  
            x += xSpeed;
         var wrappers = parent.querySelectorAll('.collapsible');  
            y += ySpeed;
         var wi = 0;  
            rotation += rotationSpeed;
         var wlen = wrappers.length;  
 
         for (; wi < wlen; wi++) {
            if (x <=0 || x >= window.innerWidth-50) xSpeed = -xSpeed*1.1;
             if (wrappers[wi].getAttribute('data-kind') === kind) {
            if (y <=0 || y >= window.innerHeight-50) ySpeed = -ySpeed*1.1;
                return wrappers[wi];  
 
             }
            emoji.style.left = x + 'px';
         }  
            emoji.style.top = y + 'px';
         return null;  
            emoji.style.transform = 'rotate(' + rotation + 'deg)';
     }  
 
      
            requestAnimationFrame(move);
     if (document.readyState === 'complete' || document.readyState === 'interactive') {
        }
         initCollapse();  
        move();
     } else {
    }
        document.addEventListener('DOMContentLoaded', initCollapse);  
 
    }  
    // ===== Фон =====
})();
    function flickerBackground() {
        document.body.style.backgroundColor = randomItem(colors);
        setTimeout(flickerBackground, Math.random()*200);
    }
 
    // ===== Меняем текст =====
    function changeText() {
        var texts = ['ХАОС!','БЕЗУМИЕ!','АААА!','ПОМОГИ!','СТОП!','SOS!','🎪 ЦИРК! 🎪'];
        chaosText.textContent = randomItem(texts);
        chaosText.style.color = randomItem(colors);
        setTimeout(changeText, Math.random()*500);
    }
 
    // ===== Создание спрайтов =====
    function createImageSprite() {
        var img = document.createElement('div');
        img.className = 'sprite';
        img.style.width = (Math.random()*100+50) + 'px';
        img.style.height = (Math.random()*100+50) + 'px';
        img.style.backgroundColor = randomItem(colors);
        img.style.borderRadius = (Math.random()>0.5 ? '50%' : '0');
        img.style.left = (Math.random()*window.innerWidth)+'px';
        img.style.top = (Math.random()*window.innerHeight)+'px';
        img.style.opacity = (Math.random()*0.7+0.3);
        document.body.appendChild(img);
 
        var x = parseFloat(img.style.left);
         var y = parseFloat(img.style.top);
         var xSpeed = (Math.random()-0.5)*8;
         var ySpeed = (Math.random()-0.5)*8;
         var scale = 1;
         var scaleSpeed = (Math.random()-0.5)*0.1;
 
         function move() {
            x += xSpeed;
            y += ySpeed;
            scale += scaleSpeed;
 
             if (x<=0 || x>=window.innerWidth-100) xSpeed=-xSpeed*1.05;
            if (y<=0 || y>=window.innerHeight-100) ySpeed=-ySpeed*1.05;
            if (scale<=0.3 || scale>=2) scaleSpeed=-scaleSpeed;
 
            img.style.left = x+'px';
             img.style.top = y+'px';
            img.style.transform = 'scale(' + scale + ')';
            requestAnimationFrame(move);
         }
         move();
     }
 
    // ===== Интервалы =====
     setInterval(createEmojiSprite, 100);
     setInterval(createImageSprite, 300);
    flickerBackground();
    changeText();
 
    // ===== Дрожание страницы =====
    function shakePage() {
        document.body.style.transform = 'translate(' + (Math.random()*20-10) + 'px,' + (Math.random()*20-10) + 'px)';
         setTimeout(shakePage, 50);
     }
    shakePage();
 
    // ===== Клик добавляет хаос =====
    document.body.addEventListener('click', function(){
        for (var i=0;i<10;i++){
            createEmojiSprite();
            createImageSprite();
        }
    });
 
    // ===== При изменении размера окна =====
    window.addEventListener('resize', function(){
        for (var i=0;i<5;i++) createEmojiSprite();
    });
}

Текущая версия от 13:10, 4 апреля 2026

(function() { 
    if (typeof mw === 'undefined' || !window.document) return; 
    
    function initCollapse() { 
        var headings = document.querySelectorAll('.chem-heading'); 
        var hi = 0; 
        var len = headings.length; 
        for (; hi < len; hi++) { 
            (function(node) { 
                if (node.getAttribute('data-chem-attached')) return; 
                node.setAttribute('data-chem-attached', '1'); 
                node.style.cursor = 'pointer'; 
                node.addEventListener('click', function() { 
                    var kind = node.getAttribute('data-kind') || ''; 
                    var wrapper = findWrapper(node, kind); 
                    if (!wrapper) return; 
                    var btn = node.querySelector('.collapse-btn'); 
                    
                    if (wrapper.classList.contains('collapsed')) { 
                        wrapper.classList.remove('collapsed'); 
                        wrapper.classList.add('expanded'); 
                        wrapper.style.maxHeight = wrapper.scrollHeight + 'px'; 
                        if (btn) btn.textContent = 'свернуть'; 
                        var cleanup = function() { 
                            wrapper.style.maxHeight = ''; 
                            wrapper.removeEventListener('transitionend', cleanup); 
                        }; 
                        wrapper.addEventListener('transitionend', cleanup); 
                    } else { 
                        var currentHeight = wrapper.scrollHeight; 
                        wrapper.style.maxHeight = currentHeight + 'px'; 
                        wrapper.offsetHeight; 
                        wrapper.classList.remove('expanded'); 
                        wrapper.classList.add('collapsed'); 
                        wrapper.style.maxHeight = '0px'; 
                        if (btn) btn.textContent = 'развернуть'; 
                    } 
                }); 
            })(headings[hi]); 
        } 
    } 
    
    function findWrapper(node, kind) { 
        var parent = node.parentNode; 
        if (!parent) return null; 
        var wrappers = parent.querySelectorAll('.collapsible'); 
        var wi = 0; 
        var wlen = wrappers.length; 
        for (; wi < wlen; wi++) { 
            if (wrappers[wi].getAttribute('data-kind') === kind) { 
                return wrappers[wi]; 
            } 
        } 
        return null; 
    } 
    
    if (document.readyState === 'complete' || document.readyState === 'interactive') { 
        initCollapse(); 
    } else { 
        document.addEventListener('DOMContentLoaded', initCollapse); 
    } 
})();