-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
209 lines (195 loc) · 7.25 KB
/
popup.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/* polyDorms: A Chrome Extension for managing Cal Poly's new dorm names...
* Developed by Justin Mo & Josiah Pang, Summer 2018
* Source: https://github.com/ohnoitsjmo/polyDorms
* Copyright (C) 2018-present
*
* Note: We are in no way affiliated with Cal Poly University Housing
*
* A: yakʔitʸutʸu
* B: elewexe
* C: nipumuʔ
* D: tiłhini
* E: tsɨtqawɨ
* F: tšɨłkukunɨtš
* G: tsɨtpxatu
* H: tsɨtkawayu
*/
// Copies the correct text
function copyText(text) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Text copied to clipboard');
})
.catch(err => {
// This can happen if the user denies clipboard permissions:
console.error('Could not copy text: ', err);
});
}
document.addEventListener('dragstart', function (event) {
event.dataTransfer.setData('Text', event.target.innerHTML);
});
//Add Event Listeners to Button Click
document.addEventListener("DOMContentLoaded", function () {
var playArray = [0, 0, 0, 0, 0, 0, 0, 0];
// Text
var eventA = document.getElementById('copy-a');
var eventB = document.getElementById('copy-b');
var eventC = document.getElementById('copy-c');
var eventD = document.getElementById('copy-d');
var eventE = document.getElementById('copy-e');
var eventF = document.getElementById('copy-f');
var eventG = document.getElementById('copy-g');
var eventH = document.getElementById('copy-h');
// Audio
var playA = document.getElementById('play-a');
var playB = document.getElementById('play-b');
var playC = document.getElementById('play-c');
var playD = document.getElementById('play-d');
var playE = document.getElementById('play-e');
var playF = document.getElementById('play-f');
var playG = document.getElementById('play-g');
var playH = document.getElementById('play-h');
// Misc
var aboutLink = document.getElementById('about-link');
eventA.addEventListener('click', function() {
copyText('yakʔitʸutʸu');
eventA.firstChild.data = "Copied!";
setTimeout(function(){ eventA.firstChild.data = "yakʔitʸutʸu"; }, 1500);
});
eventB.addEventListener('click', function() {
copyText('elewexe');
eventB.firstChild.data = "Copied!";
setTimeout(function(){ eventB.firstChild.data = "elewexe"; }, 1500);
});
eventC.addEventListener('click', function() {
copyText('nipumuʔ');
eventC.firstChild.data = "Copied!";
setTimeout(function(){ eventC.firstChild.data = "nipumuʔ"; }, 1500);
});
eventD.addEventListener('click', function() {
copyText('tiłhini');
eventD.firstChild.data = "Copied!";
setTimeout(function(){ eventD.firstChild.data = "tiłhini"; }, 1500);
});
eventE.addEventListener('click', function() {
copyText('tsɨtqawɨ');
eventE.firstChild.data = "Copied!";
setTimeout(function(){ eventE.firstChild.data = "tsɨtqawɨ"; }, 1500);
});
eventF.addEventListener('click', function() {
copyText('tšɨłkukunɨtš');
eventF.firstChild.data = "Copied!";
setTimeout(function(){ eventF.firstChild.data = "tšɨłkukunɨtš"; }, 1500);
});
eventG.addEventListener('click', function() {
copyText('tsɨtpxatu');
eventG.firstChild.data = "Copied!";
setTimeout(function(){ eventG.firstChild.data = "tsɨtpxatu"; }, 1500);
});
eventH.addEventListener('click', function() {
copyText('tsɨtkawayu');
eventH.firstChild.data = "Copied!";
setTimeout(function(){ eventH.firstChild.data = "tsɨtkawayu"; }, 1500);
});
playA.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/a.mp3"
myAudio.play();
playArray[0] = 1;
});
playB.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/b.mp3"
myAudio.play();
playArray[1] = 1;
});
playC.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/c.mp3"
myAudio.play();
playArray[2] = 1;
});
playD.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/d.mp3"
myAudio.play();
playArray[3] = 1;
});
playE.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/e.mp3"
myAudio.play();
playArray[4] = 1;
});
playF.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/f.mp3"
myAudio.play();
playArray[5] = 1;
});
playG.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/g.mp3"
myAudio.play();
playArray[6] = 1;
});
playH.addEventListener('click', function() {
var myAudio = new Audio();
myAudio.src = "assets/h.mp3"
myAudio.play();
playArray[7] = 1;
for (var i=0; i<playArray.length; i++) {
if (playArray[i] == 0) {
return;
}
}
myAudio.src = "assets/meme.mp3"
myAudio.play();
playArray = [0, 0, 0, 0, 0, 0, 0, 0];
var sheet = document.createElement('style');
var element = document.getElementById("stars");
element.classList.remove("hidden");
sheet.innerHTML = ".stars {display:block;}";
document.body.appendChild(sheet);
setTimeout(easterEgg, 600);
});
function easterEgg() {
var sheet = document.createElement('style');
sheet.innerHTML = ".btn-primary {background-color:#b4a76c;}";
document.body.appendChild(sheet);
setTimeout(function(){ document.body.removeChild(sheet); }, 500);
setTimeout(easterEgg2, 900);
}
function easterEgg2() {
var sheet = document.createElement('style');
sheet.innerHTML = ".btn-primary {background-color:#b4a76c;}";
document.body.appendChild(sheet);
setTimeout(function(){ document.body.removeChild(sheet); }, 500);
setTimeout(easterEgg3, 900);
}
function easterEgg3() {
var sheet = document.createElement('style');
sheet.innerHTML = ".btn-primary {background-color:#b4a76c;}";
document.body.appendChild(sheet);
setTimeout(function(){ document.body.removeChild(sheet); }, 700);
setTimeout(easterEgg4, 900);
}
function easterEgg4() {
var sheet = document.createElement('style');
sheet.innerHTML = ".btn-primary {background-color:#b4a76c;}";
document.body.appendChild(sheet);
setTimeout(function(){ document.body.removeChild(sheet); }, 500);
setTimeout(easterEgg5, 900);
}
function easterEgg5() {
var sheet = document.createElement('style');
sheet.innerHTML = ".btn-primary {background-color:#b4a76c;}";
document.body.appendChild(sheet);
setTimeout(function(){ document.body.removeChild(sheet); }, 500);
var element = document.getElementById("stars");
element.classList.add("hidden");
}
aboutLink.onclick = function() {
chrome.tabs.create({active: true, url: "https://github.com/ohnoitsjmo/polyDorms"})
}
});