This repository has been archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
party-llamacorn.user.js
71 lines (59 loc) · 1.89 KB
/
party-llamacorn.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// ==UserScript==
// @name Party Llamacorn
// @namespace https://central.tri.be/
// @version 0.1
// @description Party time!
// @author Paul Kim, Aaron Hanson
// @include /https?:\/\/central.tri.be\/issues\/[0-9]+\/?/
// @grant none
// ==/UserScript==
( function($) {
var showLlamacorn = function() {
var status = document.querySelector('#content .meta td.status').textContent;
return status == 'Pending Merge' || status == 'Complete';
};
var setStyles = function() {
var css = '.llamacorn-wrapper{position:absolute;top:50%;transform:translateY(-50%);width:100%;pointer-events:none;z-index:9999;overflow:hidden}.llamacorn{position:relative;left:0;transform:translateX(-100%);transition:1.3s}.llamacorn-fly{left:100%;transform:translateX(0)}';
var head = document.head;
var style = document.createElement('style');
style.type = 'text/css';
style.appendChild(document.createTextNode(css));
head.appendChild(style);
};
var createImage = function() {
var image = document.createElement('img');
image.src = 'https://central.tri.be/attachments/105168/llamacorn.png';
image.classList.add('llamacorn');
return image;
};
var createImageWrapper = function() {
var wrapper = document.createElement('div');
wrapper.classList.add('llamacorn-wrapper');
wrapper.appendChild(createImage());
document.body.appendChild(wrapper);
};
var imageLoaded = function() {
$('.llamacorn').addClass('llamacorn-fly');
};
var removeLlamacorn = function() {
$('.llamacorn-wrapper').remove();
};
var bindEvent = function() {
$('.llamacorn').each(function() {
if( this.complete ) {
imageLoaded.call( this );
} else {
$(this).one('load', imageLoaded);
}
});
$('.llamacorn').on('transitionend', removeLlamacorn);
};
var init = function() {
if (showLlamacorn()) {
setStyles();
createImageWrapper();
bindEvent();
}
};
init();
} )(jQuery);