imgur animated upvote/downvote fireworks

adds an animation to upvote/downvote

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         imgur animated upvote/downvote fireworks
// @namespace    http://porath.org/
// @version      0.25
// @description  adds an animation to upvote/downvote
// @author       porath
// @match        http://imgur.com/*
// @match        https://imgur.com/*
// @grant        none
// ==/UserScript==

$('#mainUpArrow').append('<div id="upvote_firework" style="display: none; position: absolute"><img src="//i.imgur.com/YEzlDPG.png" /></div>');
$('#mainDownArrow').append('<div id="downvote_firework" style="display: none; position: absolute"><img src="//i.imgur.com/5WTwxi9.png" /></div>');

$('#mainUpArrow').on('click', function () {
    if ($('#mainUpArrow').hasClass('pushed')) {
        return;
    }

    $('#upvote_firework').css("top", -39);
    $('#upvote_firework').css("left", -80);

    $('#upvote_firework').show();

    window.setTimeout(function() { // wait, then hide the animation
        $('#upvote_firework').hide();
    }, 1000);
});

$('#mainDownArrow').on('click', function () {
    if ($('#mainDownArrow').hasClass('pushed')) {
        return;
    }

    $('#downvote_firework').css("top", -39);
    $('#downvote_firework').css("left", -39);

    $('#downvote_firework').show();

    window.setTimeout(function() { // wait, then hide the animation
        $('#downvote_firework').hide();
    }, 1000);
});

function animateCommentUpvote (a) {
    if (a.parent().find('.comment_upvote').length == 0) {
        a.closest('.up').append('<div class="comment_upvote" style="display: none; position: absolute; width: 80px; height: 45px;"><img style="width: 80px !important; height: 45px !important;" src="//i.imgur.com/YEzlDPG.png" /></div>');
    }

    a.parent().find('.comment_upvote').css("top", -10);
    a.parent().find('.comment_upvote').css("left", -15);

    a.parent().find('.comment_upvote').show();

    window.setTimeout(function() { // wait, then hide the animation
        $('.comment_upvote').hide();
    }, 1000);
};

function animateCommentDownvote (a) {
    if (a.parent().find('.comment_downvote').length == 0) {
        a.closest('.up').append('<div class="comment_downvote" style="display: none; position: absolute; width: 80px; height: 45px;"><img style="width: 80px !important; height: 45px !important;" src="//i.imgur.com/5WTwxi9.png" /></div>');
    }

    a.parent().find('.comment_downvote').css("top", -10);
    a.parent().find('.comment_downvote').css("left", -15);

    a.parent().find('.comment_downvote').show();

    window.setTimeout(function() { // wait, then hide the animation
        $('.comment_downvote').hide();
    }, 1000);
};

$('#comments-container').on('click', '.icon-upvote', function () {
    if ($(this).parent().hasClass('pushed')) {
        return;
    }

    animateCommentUpvote($(this));
});

$('#comments-container').on('click', '.up.arrow', function () {
    if ($(this).hasClass('pushed')) {
        return;
    }

    animateCommentUpvote($(this).find('.icon-upvote'));
});

$('#comments-container').on('click', '.icon-downvote', function () {
    if ($(this).parent().hasClass('pushed')) {
        return;
    }

    animateCommentDownvote($(this));
});

$('#comments-container').on('click', '.down.arrow', function () {
    if ($(this).parent().hasClass('pushed')) {
        return;
    }

    animateCommentDownvote($(this).find('.icon-downvote'));
});