adds an animation to upvote/downvote
目前為
// ==UserScript==
// @name imgur animated upvote/downvote fireworks
// @namespace http://porath.org/
// @version 0.20
// @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);
});
$('#comments-container').on('click', '.icon-upvote', function () {
if ($(this).parent().hasClass('pushed')) {
return;
}
if ($(this).parent().find('.comment_upvote').length == 0) {
$(this).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>');
}
$(this).parent().find('.comment_upvote').css("top", -10);
$(this).parent().find('.comment_upvote').css("left", -15);
$(this).parent().find('.comment_upvote').show();
window.setTimeout(function() { // wait, then hide the animation
$('.comment_upvote').hide();
}, 1000);
});
$('#comments-container').on('click', '.icon-downvote', function () {
if ($(this).parent().hasClass('pushed')) {
return;
}
if ($(this).parent().find('.comment_downvote').length == 0) {
$(this).closest('.down').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>');
}
$(this).parent().find('.comment_downvote').css("top", 15);
$(this).parent().find('.comment_downvote').css("left", -15);
$(this).parent().find('.comment_downvote').show();
window.setTimeout(function() { // wait, then hide the animation
$('.comment_downvote').hide();
}, 1000);
});