-
Notifications
You must be signed in to change notification settings - Fork 2
/
pepe.js
66 lines (58 loc) · 1.89 KB
/
pepe.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
'use strict';
function getRekt(element) {
var rekt = element.getBoundingClientRect();
return {
top: rekt.top + document.body.scrollTop + 'px',
left: rekt.left + document.body.scrollLeft + 'px',
right: rekt.right + 'px',
height: rekt.height + 'px',
width: rekt.width + 'px'
};
}
// Kills existing pepes with fire.
function blazeIt() {
var pepes = document.getElementsByClassName('pepe');
while (pepes[0]) {
pepes[0].parentNode.removeChild(pepes[0]);
}
}
function dankify(element, url) {
var meme = new Image();
meme.src = url;
meme.className = 'pepe';
meme.style.position = 'absolute';
var rekt = getRekt(element);
meme.style.zIndex = '420420';
for (var key in rekt) {
meme.style[key] = rekt[key];
}
document.body.appendChild(meme);
}
function dankception() {
blazeIt();
var PEPE_URL = chrome.extension.getURL('img/pepe.png');
var RARE_SAD_PEPE_URL = chrome.extension.getURL('img/rare_sad_pepe.png');
var RARE_MINION_PEPE_URL = chrome.extension.getURL('img/rare_minion_pepe.png');
[].forEach.call(document.getElementsByClassName('faceBox'), function (victim) {
var rare = Math.random();
if(rare<0.1) { //one in ten pepes has the feels
return dankify(victim, RARE_SAD_PEPE_URL);
} else if (rare < 0.15) { //one in twenty pepes is secretly an evil minion
return dankify(victim, RARE_MINION_PEPE_URL);
} else {
return dankify(victim, PEPE_URL);
}
});
[].forEach.call(document.getElementsByClassName('tagBox'), function (victim) {
var rare = Math.random();
if(rare<0.1) { //one in ten pepes has the feels
return dankify(victim, RARE_SAD_PEPE_URL);
} else if (rare < 0.15) { //one in twenty pepes is secretly an evil minion
return dankify(victim, RARE_MINION_PEPE_URL);
} else {
return dankify(victim, PEPE_URL);
}
});
}
window.onclick = dankception;
setInterval(dankception, 100)