Vote Explosion Effect (o_o)

Robi BUUUM.

Version au 10/02/2016. Voir la dernière version.

Vous devrez installer une extension telle que Tampermonkey, Greasemonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Violentmonkey pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey ou Userscripts pour installer ce script.

Vous devrez installer une extension telle que Tampermonkey pour installer ce script.

Vous devrez installer une extension de gestionnaire de script utilisateur pour installer ce script.

(J'ai déjà un gestionnaire de scripts utilisateur, laissez-moi l'installer !)

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension telle que Stylus pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

Vous devrez installer une extension du gestionnaire de style pour utilisateur pour installer ce style.

(J'ai déjà un gestionnaire de style utilisateur, laissez-moi l'installer!)

// ==UserScript==
// @name            Vote Explosion Effect (o_o)
// @namespace       voteexplosion
// @description     Robi BUUUM.
// @include         http://*.wykop.pl/*
// @include         http://*.mirkoczat.pl/*
// @version         2.2
// ==/UserScript==

//                                     88
//                                     ""
//
//   ,adPPYba,  8b,dPPYba,   ,adPPYba, 88  ,adPPYba,
//  a8"     "8a 88P'    "8a a8"     "" 88 a8P_____88
//  8b       d8 88       d8 8b         88 8PP"""""""
//  "8a,   ,a8" 88b,   ,a8" "8a,   ,aa 88 "8b,   ,aa
//   `"YbbdP"'  88`YbbdP"'   `"Ybbd8"' 88  `"Ybbd8"'
//              88                    ,88
//              88                  888P"




var options = {
    particleSpread:        150,
    particleCount:          20
};

if(localStorage.getItem("particleSpread")) {
    options.particleSpread = localStorage.getItem("particleSpread");
}

if(localStorage.getItem("particleCount")) {
    options.particleCount = localStorage.getItem("particleCount");
}


//                                88
//              ,d                88
//              88                88
//  ,adPPYba, MM88MMM 8b       d8 88  ,adPPYba,
//  I8[    ""   88    `8b     d8' 88 a8P_____88
//   `"Y8ba,    88     `8b   d8'  88 8PP"""""""
//  aa    ]8I   88,     `8b,d8'   88 "8b,   ,aa
//  `"YbbdP"'   "Y888     Y88'    88  `"Ybbd8"'
//                        d8'
//                       d8'


$('head').append('<style type="text/css">\
                    .particleGreen {\
                        color: #3b915f;\
                    }\
                    .particleGray {\
                        color: #999;\
                    }\
                    .particleGolden {\
                        color: #c7a054;\
                    }\
                    .particleRed {\
                        color: #c0392b;\
                    }\
                    .particle {\
                        position: absolute;\
                        pointer-events: none;\
                        z-index: 696969;\
                        transition: 1.5s all cubic-bezier(0.000, 0.895, 0.985, 1.005);\
                    }\
                    .particle i.fa {\
                        font-size: 1.5rem;\
                    }\
                    .votersContainer {\
                        min-height: 18px;\
                        margin-bottom: 6px;\
                    }\
                    body li.entry ul.responsive-menu b a.affect {\
                        color: #c0392b !important;\
                    }\
                    body li.entry .lcontrast:hover ul.responsive-menu b a.affect {\
                        color: #c0392b !important;\
                    }\
                 </style>');



//     ad88                         88                  88
//    d8"                           88                  ""
//    88                            88
//  MM88MMM 88       88 8b,dPPYba,  88   ,d8  ,adPPYba, 88  ,adPPYba,
//    88    88       88 88P'   `"8a 88 ,a8"  a8"     "" 88 a8P_____88
//    88    88       88 88       88 8888[    8b         88 8PP"""""""
//    88    "8a,   ,a88 88       88 88`"Yba, "8a,   ,aa 88 "8b,   ,aa
//    88     `"YbbdP'Y8 88       88 88   `Y8a `"Ybbd8"' 88  `"Ybbd8"'
//                                                     ,88
//                                                   888P"



function getParticlePosition(x, y, direction) {

    'use strict';

    var randomX = x - Math.floor((Math.random() * options.particleSpread) + 1 - (options.particleSpread / 2)),
        randomY = y - Math.floor((Math.random() * options.particleSpread) + 1 - (options.particleSpread / 2)),
        randomDirection = Math.floor((Math.random() * 100) + 1);

    if(direction == 'down') {
        randomY = randomY + randomDirection;
    } else {
        randomY = randomY - randomDirection;
    }

    return [randomX, randomY];
}

function randomRotate() {
    return Math.floor((Math.random() * 360) + 1);
}

function randomZoom() {
    return 2 - (Math.floor((Math.random() * 200) + 1) / 100);
}

function particleExplode(iconClass, colorClass, direction, click) {

    'use strict';

    var body = $('body'),
        posX = click.pageX,
        posY = click.pageY,
        particleRandomClass = 'particle_' + Math.random().toString(36).substring(4),
        particlesArray = [],
        particle = '';

    for (var i = 0; i < options.particleCount; i++) {
        var particleID = 'particle_' + Math.random().toString(36).substring(4),
            particleClass = 'particle ' + colorClass + ' ' + particleRandomClass,
            particleStyle = 'top: ' + posY + 'px; left: ' + posX + 'px;',
            particle = particle + '<div class="' + particleClass + '" style="' + particleStyle + '" id="' + particleID + '"><i class="fa ' + iconClass + '"></i></div>';

            particlesArray[i] = particleID;
    }

    body.append(particle);

    for (var i = 0; i < options.particleCount; i++) {
        var particlePosition = getParticlePosition(posX, posY, direction),
            rotate = randomRotate(),
            zoom = randomZoom(),
            fadeOutTime = 300 + Math.floor((Math.random() * 1200) + 1);
        $('#' + particlesArray[i])
        .fadeIn(1, function(){
            $(this)
                .css('top', particlePosition[1] + 'px')
                .css('left', particlePosition[0] + 'px')
                .css('transform', 'rotate(' + rotate + 'deg) scale(' + randomZoom() + ')')
                .fadeOut(fadeOutTime, function(){
                    $(this).remove();
                });
        });
    }
}




//     ad88 88
//    d8"   ""
//    88
//  MM88MMM 88 8b,     ,d8 8b       d8
//    88    88  `Y8, ,8P'  `8b     d8'
//    88    88    )888(     `8b   d8'
//    88    88  ,d8" "8b,    `8b,d8'
//    88    88 8P'     `Y8     Y88'
//                             d8'
//                            d8'


if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
    // fajerfoksy chodzą źle, trzeba zmniejszyć liczbę cząsteczków :<
    options.particleCount = 10;
}


//  88,dPYba,,adPYba,   ,adPPYba, 8b,dPPYba,  88       88
//  88P'   "88"    "8a a8P_____88 88P'   `"8a 88       88
//  88      88      88 8PP""""""" 88       88 88       88
//  88      88      88 "8b,   ,aa 88       88 "8a,   ,a88
//  88      88      88  `"Ybbd8"' 88       88  `"YbbdP'Y8


$('.dropdown.right.m-hide div ul li:last').before('<li><a href="#" title="" id="openSettingsWindow"><i class="fa fa-wrench"></i> <span>opcje skryptu</span></a></li>');

$(document).on('click', '#openSettingsWindow', function(){

    var userNick = $('.dropdown-show.auto > img.avatar').attr('alt');

    if(localStorage.getItem("particleSpread")) {
        var particleSpread = localStorage.getItem("particleSpread");
    } else {
        var particleSpread = options.particleSpread;
    }

    if(localStorage.getItem("particleCount")) {
        var particleCount = localStorage.getItem("particleCount");
    } else {
        var particleCount = options.particleCount;
    }

    var settingsForm = '<br>\
                            <p>Tutaj możesz zmienić ustawienia skryptu.</p>\
                            <br>\
                                <label for="particleSpread">wielkość wybuchu (px)</label>\
                                <input type="text" class="form-control" id="particleSpread" value="' + particleSpread + '">\
                            <br>\
                            <br>\
                                <label for="particleCount">liczba cząsteczek (px)</label>\
                                <input type="text" class="form-control" id="particleCount" value="' + particleCount + '">\
                            <br>\
                            <div style="margin: 15px; text-align: center;" id="msgContainer">Zmiany zapisują się automatycznie.</div>\
                            <div style="text-align: center;" id="msgContainer">\
                                <input class="bigred closepreview" style="text-align:center; cursor: pointer;" type="button" value="zapisz ustawienia" id="">\
                            </div>',
        settingsPropaganda = '<br><hr><br>\
                                <img src="http://xs.cdn03.imgwykop.pl/c3397992/Dreszczyk_sBtjObQZ5c,q48.jpg" style="float:left; margin-right: 10px;">Cześć ' + userNick + '. Tutaj twórca tego skryptu, @Dreszczyk. Jeżeli chcesz podziękować z ten skrypt, to wiedz, że bardzo lubie <a href="http://www.wykop.pl/ludzie/Dreszczyk/">subskrybowanie mojego profilu</a>.',
        settingsWindow = '<div id="violationContainer">\
                                <div class="overlay" style="display: block;"></div>\
                                <div id="zgloszenie" style="display: none;" class="normal m-set-fullwidth m-reset-top m-reset-margin m-reset-left">\
                                    <form id="scriptSettings">\
                                        <div class="header">\
                                            <a href="#" title="zamknij" class="fright close"><span class="icon inlblk mini closepreview"><i class="fa fa-times"></i></span></a>\
                                            <span class="title">Vote Explosion Script - ustawienia</span>\
                                        </div>\
                                        <div class="view" style="max-height: initial;">' + settingsForm + '' + settingsPropaganda + '</div>\
                                    </form>\
                                </div>\
                            </div>';

    $('body').prepend(settingsWindow).find('#zgloszenie').fadeIn();
});

$(document).on('click', 'div.overlay', function(){
    $('#violationContainer').remove();
});

$(document).on('change', '#scriptSettings input', function(){
    localStorage.setItem($(this).attr('id'), $(this).val());
    options[$(this).attr('id')] = $(this).val();
    $('#msgContainer').html('Zmiany zapisują się automatycznie - <b>zapisane</b>.');
});


//              88
//              88
//              88
//  8b,dPPYba,  88 88       88 ,adPPYba, 8b       d8
//  88P'    "8a 88 88       88 I8[    "" `8b     d8'
//  88       d8 88 88       88  `"Y8ba,   `8b   d8'
//  88b,   ,a8" 88 "8a,   ,a88 aa    ]8I   `8b,d8'
//  88`YbbdP"'  88  `"YbbdP'Y8 `"YbbdP"'     Y88'
//  88                                       d8'
//  88                                      d8'


$('body').on('click', 'a.button.mikro.ajax', function (click) {
    if($(this).parent().find('b.voted.plus').length) {
        particleExplode('fa-minus', 'particleRed', 'down', click);
    } else {
        particleExplode('fa-plus', 'particleGreen', 'up', click);
    }
});

$('body').on('click', 'div.avatar-plus img', function (click) {
    particleExplode('fa-plus', 'particleGreen', 'up', click);
});


//                             88
//                             88
//                             88
//       ,adPPYba, 88       88 88,dPPYba,
//       I8[    "" 88       88 88P'    "8a
//        `"Y8ba,  88       88 88       d8
//       aa    ]8I "8a,   ,a88 88b,   ,a8"
//       `"YbbdP"'  `"YbbdP'Y8 8Y"Ybbd8"'


$('body').on('click', 'a[title="Dodaj do obserwowanych"]', function (click) {
    particleExplode('fa-eye', 'particleGreen', 'up', click);
});

$('body').on('click', 'a[title="Usuń z obserwowanych"]', function (click) {
    particleExplode('fa-eye-slash', 'particleGray', 'down', click);
});


//           88 88
//           88 ""
//           88
//   ,adPPYb,88 88  ,adPPYb,d8
//  a8"    `Y88 88 a8"    `Y88
//  8b       88 88 8b       88
//  "8a,   ,d88 88 "8a,   ,d88
//   `"8bbdP"Y8 88  `"YbbdP"Y8
//                  aa,    ,88
//                   "Y8bbdP"


$('body').on('click', '.diggbox span', function (click) {
    if($(this).parent().parent().hasClass('digout')) {
        particleExplode('fa-thumbs-down', 'particleRed', 'down', click);
    } else {
        particleExplode('fa-thumbs-up', 'particleGreen', 'up', click);
    }
});


//     ad88            88 88
//    d8"              88 88
//    88               88 88
//  MM88MMM ,adPPYba,  88 88  ,adPPYba,  8b      db      d8
//    88   a8"     "8a 88 88 a8"     "8a `8b    d88b    d8'
//    88   8b       d8 88 88 8b       d8  `8b  d8'`8b  d8'
//    88   "8a,   ,a8" 88 88 "8a,   ,a8"   `8bd8'  `8bd8'
//    88    `"YbbdP"'  88 88  `"YbbdP"'      YP      YP


$('body').on('click', 'a[title="Dodaj do obserwowanych"]', function (click) {
    particleExplode('fa-eye', 'particleGreen', 'down', click);
});

$('body').on('click', 'a[title="Usuń z obserwowanych"]', function (click) {
    particleExplode('fa-eye-crossed', 'particleGray', 'up', click);
});

//     ad88
//    d8"
//    88
//  MM88MMM ,adPPYYba, 8b       d8
//    88    ""     `Y8 `8b     d8'
//    88    ,adPPPPP88  `8b   d8'
//    88    88,    ,88   `8b,d8'
//    88    `"8bbdP"Y8     "8"

$('body').on('click', 'li.entry .responsive-menu a.affect.ajax, li.iC .responsive-menu a.affect.ajax', function (click) {
    if($(this).parent().is('b')) {
        particleExplode('fa-heart-o', 'particleGray', 'down', click);
    } else {
        particleExplode('fa-heart', 'particleRed', 'up', click);
    }
});


//  88          88                        88
//  88          88                        88
//  88          88                        88
//  88,dPPYba,  88  ,adPPYba,   ,adPPYba, 88   ,d8
//  88P'    "8a 88 a8"     "8a a8"     "" 88 ,a8"
//  88       d8 88 8b       d8 8b         8888[
//  88b,   ,a8" 88 "8a,   ,a8" "8a,   ,aa 88`"Yba,
//  8Y"Ybbd8"'  88  `"YbbdP"'   `"Ybbd8"' 88   `Y8a


$('body').on('click', 'a[title="zablokuj użytkownika"]', function (click) {
    particleExplode('fa-lock', 'particleRed', 'down', click);
});

$('body').on('click', 'a[title="odblokuj użytkownika"]', function (click) {
    particleExplode('fa-unlock', 'particleGray', 'up', click);
});