MediaWiki:Gadget-nophono.js

From GigaWiki
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.



function characterToZalgo(char) {
    const zalgoUp = [
        '\u030d', '\u030e', '\u0304', '\u0305',
        '\u033f', '\u0311', '\u0306', '\u0310',
        '\u0352', '\u0357', '\u0351', '\u0307',
        '\u0308', '\u030a', '\u0342', '\u0343',
        '\u0344', '\u034a', '\u034b', '\u034c',
        '\u0303', '\u0302', '\u030c', '\u0350',
        '\u0300', '\u0301', '\u030b', '\u030f',
        '\u0312', '\u0313', '\u0314', '\u033d',
        '\u0309', '\u0363', '\u0364', '\u0365',
        '\u0366', '\u0367', '\u0368', '\u0369',
        '\u036a', '\u036b', '\u036c', '\u036d',
        '\u036e', '\u036f', '\u033e', '\u035b',
    ];
    const zalgoDown = [
        '\u0316', '\u0317', '\u0318', '\u0319',
        '\u031c', '\u031d', '\u031e', '\u031f',
        '\u0320', '\u0324', '\u0325', '\u0326',
        '\u0329', '\u032a', '\u032b', '\u032c',
        '\u032d', '\u032e', '\u032f', '\u0330',
        '\u0331', '\u0332', '\u0333', '\u0339',
        '\u033a', '\u033b', '\u033c', '\u0345',
        '\u0347', '\u0348', '\u0349', '\u034d',
        '\u034e', '\u0353', '\u0354', '\u0355',
        '\u0356', '\u0359', '\u035a', '\u0323',
    ];
    const zalgoMid = [
        '\u0315', '\u031b', '\u0340', '\u0341',
        '\u0358', '\u0321', '\u0322', '\u0327',
        '\u0328', '\u0334', '\u0335', '\u0336',
        '\u034f', '\u035c', '\u035d', '\u035e',
        '\u035f', '\u0360', '\u0362', '\u0338',
        '\u0337', '\u0361', '\u0489',
    ];
    let newChar = char;
    const numUp = Math.floor(Math.random() * 8) + 1;
    const numMid = Math.floor(Math.random() * 3);
    const numDown = Math.floor(Math.random() * 8) + 1;
    for (let i = 0; i < numUp; i++) {
        newChar += zalgoUp[Math.floor(Math.random() * zalgoUp.length)];
    }
    for (let i = 0; i < numMid; i++) {
        newChar += zalgoMid[Math.floor(Math.random() * zalgoMid.length)];
    }
    for (let i = 0; i < numDown; i++) {
        newChar += zalgoDown[Math.floor(Math.random() * zalgoDown.length)];
    }
    return newChar;
}


function typeWriterEffect(element, text, delay = 100) {
    let i = 0;
    function type() {
        if (i < text.length) {
            element.innerHTML += characterToZalgo(text.charAt(i));
            
            i++;
            setTimeout(type, delay);
        }
    }
    type();
}

function flashScreen(color = 'red') {
    const flash = document.createElement('div');
    flash.style.position = 'fixed';
    flash.style.top = '0';
    flash.style.left = '0';
    flash.style.width = '100%';
    flash.style.height = '100%';
    flash.style.backgroundColor = color;
    flash.style.zIndex = '9999';
    flash.style.opacity = '0';
    flash.style.transition = 'opacity 0.2s';
    setTimeout(() => {
        flash.style.opacity = '1';
    }, 10);
    document.body.appendChild(flash);

}


mw.loader.using([], function () {
    if (mw.config.get('wgPageName') !== "Nophono" || window.location.href.indexOf('action') !== -1) {
        return;
    }
   
    const scaryText = document.createElement('div');
    scaryText.style.position = 'absolute';
    scaryText.style.top = '50%';
    scaryText.style.left = '35%';
    scaryText.style.transform = 'translate(-50%, -50%)';
    scaryText.style.fontSize = '48px';
    scaryText.style.fontWeight = 'bold';
    scaryText.style.color = 'rgb(72, 72, 72)';
    scaryText.style.textAlign = 'center';
    scaryText.style.animation = 'shake 0.2s infinite';
    typeWriterEffect(scaryText, 'I AM WATCHING', 150);
    
    document.body.appendChild(scaryText);

    setTimeout(() => {
        flashScreen('red');
        setTimeout(() => {
            window.location.href = window.history.back() || '/';
        }, 500);
    }, 3000);
});