-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
428 lines (345 loc) · 15 KB
/
index.html
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Mood.gg Desktop (Overwatch Edition)</title>
<link rel="stylesheet" type="text/css" href="css/index.css"></link>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Insert this line above script imports -->
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<!-- Insert this line after script imports -->
<script>if (window.module) module = window.module;</script>
</head>
<body style="width:100%; height:100%; padding:0; margin:0;">
<div id ="setBindingsBox" style="display: none;">
<div id ="settings" class="verticalHorizontalCenter row">
Settings
<span style="font-size: 3vh;"> <span onClick="clearStorageButton();"> [Click the X to save your settings!] </span>
</div>
<div id ="detection" class="verticalHorizontalCenter row">
<span style="font-size: 2.5vh;"> <input id="detectionFlag" type="checkbox"> Automatic Hero Detection toggle. If you have a slower PC, turn this off! (checkmark = on) <br> </span>
</div>
<div class="verticalHorizontalCenter row">
<div id = "buttonTitle" class="trans buttonTitle">
<div class="verticalHorizontalCenterText"> Prev </div>
</div>
<div style="float:left; width: 15vh;" class="trans">
<div class="verticalHorizontalCenterText"> Control </div>
</div>
<div style="float:left; width: 15vh; margin-left: 10px;" class="trans">
<div class="verticalHorizontalCenterText"> + </div>
</div>
<button style="float:left; margin-left: 10px;" id="PREVSONGKEY" class="keyOneButton"> <div style="width:100%;" id="prevButtonText" class="verticalHorizontalCenterText">K [click to change] </div>
</button>
</div>
<div class="verticalHorizontalCenter row">
<div id = "buttonTitle" class="trans buttonTitle">
<div class="verticalHorizontalCenterText"> Play/Pause </div>
</div>
<div style="float:left; width: 15vh;" class="trans">
<div class="verticalHorizontalCenterText"> Control </div>
</div>
<div style="float:left; width: 15vh; margin-left: 10px;" class="trans">
<div class="verticalHorizontalCenterText"> + </div>
</div>
<button style="float:left; margin-left: 10px;" id="PLAYSONGKEY" class="keyOneButton"> <div style="width:100%;" id="playButtonText" class="verticalHorizontalCenterText">B [click to change] </div>
</button>
</div>
<div class="verticalHorizontalCenter row">
<div id = "buttonTitle" class="trans buttonTitle">
<div class="verticalHorizontalCenterText"> Next </div>
</div>
<div style="float:left; width: 15vh;" class="trans">
<div class="verticalHorizontalCenterText"> Control </div>
</div>
<div style="float:left; width: 15vh; margin-left: 10px;" class="trans">
<div class="verticalHorizontalCenterText"> + </div>
</div>
<button style="float:left; margin-left: 10px;" id="NEXTSONGKEY" class="keyOneButton"> <div style="width:100%;" id="nextButtonText" class="verticalHorizontalCenterText">K [click to change] </div>
</button>
</div>
<div class="verticalHorizontalCenter row">
<div id = "buttonTitle" class="trans buttonTitle">
<div class="verticalHorizontalCenterText"> Vol. Down </div>
</div>
<div style="float:left; width: 15vh;" class="trans">
<div class="verticalHorizontalCenterText"> Control </div>
</div>
<div style="float:left; width: 15vh; margin-left: 10px;" class="trans">
<div class="verticalHorizontalCenterText"> + </div>
</div>
<button style="float:left; margin-left: 10px;" id="VOLDOWNKEY" class="keyOneButton"> <div style="width:100%;" id="volDownButtonText" class="verticalHorizontalCenterText">K [click to change] </div>
</button>
</div>
<div class="verticalHorizontalCenter row">
<div id = "buttonTitle" class="trans buttonTitle">
<div class="verticalHorizontalCenterText"> Vol. Up </div>
</div>
<div style="float:left; width: 15vh;" class="trans">
<div class="verticalHorizontalCenterText"> Control </div>
</div>
<div style="float:left; width: 15vh; margin-left: 10px;" class="trans">
<div class="verticalHorizontalCenterText"> + </div>
</div>
<button style="float:left; margin-left: 10px;" id="VOLUPKEY" class="keyOneButton"> <div style="width:100%;" id="volUpButtonText" class="verticalHorizontalCenterText">K [click to change] </div>
</button>
</br>
</div>
</br>
</br>
</br>
<div id ="closeButton" class="glyphicon glyphicon-remove"></div>
</br>
</br>
</br>
</br>
</div>
<img id="gear" src="assets/gear.svg"></img>
<webview id="foo" autosize="on" src="https://mood.gg/ow2" style="width:100%; height:100%;"></webview>
<div style='display:none;'>
<textarea id="newnet" style="width:100%; height:200px;"></textarea><br />
</div>
</body>
<!-- normal script imports etc -->
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<script>
var openCVReady = false;
var template = null;
function onOpenCvReady() {
console.log("Loaded OpenCV");
openCVReady = true;
// POTG template.
var image = new Image();
image.onload = function () {
let tmpImage = image;
template = cv.imread(tmpImage);
};
image.src = 'template.jpg?' + new Date().getTime();
}
</script>
<script async src="opencv.js" onload="onOpenCvReady();" type="text/javascript"></script>
<script>
var {ipcRenderer} = require('electron');
var heroDetectionOn = false;
document.addEventListener("keydown", function (e) {
console.log(e.which)
if (e.which === 76) {
require('remote').getCurrentWindow().toggleDevTools();
} else if (e.which === 80) {
location.reload();
}
});
$( document ).ready(function() {
require('./renderer.js');
var playSet = false;
var nextSet = false;
var prevSet = false;
var volDownSet = false;
var volUpSet = false;
var vol = 50;
$('#setBindingsBox').hide()
//document.getElementById("setBindingsBox").style.display= "none"
console.log( "ready!" );
ipcRenderer.send('READY', "READY")
$('#closeButton').click(function() {
console.log("hi");
$('#setBindingsBox').hide()
if(document.getElementById("prevButtonText").innerHTML == "Type new key now. LETTERS ONLY!") {
document.getElementById("prevButtonText").innerHTML = "N/A"
}
if(document.getElementById("playButtonText").innerHTML == "Type new key now. LETTERS ONLY!") {
document.getElementById("playButtonText").innerHTML = "N/A"
}
if(document.getElementById("nextButtonText").innerHTML == "Type new key now. LETTERS ONLY!") {
document.getElementById("nextButtonText").innerHTML = "N/A"
}
if(document.getElementById("volDownButtonText").innerHTML == "Type new key now. LETTERS ONLY!") {
document.getElementById("volDownButtonText").innerHTML = "N/A"
}
if(document.getElementById("volUpButtonText").innerHTML == "Type new key now. LETTERS ONLY!") {
document.getElementById("volUpButtonText").innerHTML = "N/A"
}
playSet = false;
nextSet = false;
prevSet = false;
volDownSet = false;
volUpSet = false;
setButtons();
});
$('#gear').click(function() {
$('#setBindingsBox').show()
//document.getElementById("setBindingsBox").style.display= "block"
})
$('#PREVSONGKEY').click(function() {
document.getElementById("prevButtonText").innerHTML = "Type new key now. LETTERS ONLY!"
prevSet = true;
})
$('#PLAYSONGKEY').click(function() {
document.getElementById("playButtonText").innerHTML = "Type new key now. LETTERS ONLY!"
playSet = true;
})
$('#NEXTSONGKEY').click(function() {
document.getElementById("nextButtonText").innerHTML = "Type new key now. LETTERS ONLY!"
nextSet = true;
})
$('#VOLDOWNKEY').click(function() {
document.getElementById("volDownButtonText").innerHTML = "Type new key now. LETTERS ONLY!"
volDownSet = true;
})
$('#VOLUPKEY').click(function() {
document.getElementById("volUpButtonText").innerHTML = "Type new key now. LETTERS ONLY!"
volUpSet = true;
})
$(document).keypress(function (e) {
if (/[a-zA-Z]/.test(e.key)){
if(playSet == true) {
console.log("Set play to ", e.key)
document.getElementById("playButtonText").innerHTML = e.key.toUpperCase() + " [click to change]";
playSet = false;
}
if(nextSet == true) {
console.log("Set next to ", e.key)
document.getElementById("nextButtonText").innerHTML = e.key.toUpperCase() + " [click to change]";
nextSet = false;
}
if(prevSet == true) {
console.log("Set prev to ", e.key)
document.getElementById("prevButtonText").innerHTML = e.key.toUpperCase() + " [click to change]";
prevSet = false;
}
if(volDownSet == true) {
console.log("Set vol down to ", e.key)
document.getElementById("volDownButtonText").innerHTML = e.key.toUpperCase() + " [click to change]";
volDownSet = false;
}
if(volUpSet == true) {
console.log("Set vol up to ", e.key)
document.getElementById("volUpButtonText").innerHTML = e.key.toUpperCase() + " [click to change]";
volUpSet = false;
}
}
else if (playSet || nextSet || prevSet || volDownSet || volUpSet) {
alert("Please type in a letter!")
}
});
});
const webview = document.querySelector('webview')
// Keep track of webiew states.
// If we get two loadstops in a row.
const loadstart = () => {
console.log("LOADSTART")
}
const loadstop = () => {
console.log("LOADSTOP");
for (var i = 0; i < 10; i++) {
tryAndPlayVideo(i)
}
}
function tryAndPlayVideo(i) {
var command = "if (document.getElementById('playPauseButton').name == 'play' && playing == false) { player.playVideo(); }"
setTimeout(function(e) {
console.log("Trying to play! " + i);
webview.executeJavaScript(command);
}, 1000 * i);
}
function setButtons() {
var arr = [];
var prevText = document.getElementById("prevButtonText").innerHTML;
var playText = document.getElementById("playButtonText").innerHTML;
var nextText = document.getElementById("nextButtonText").innerHTML;
if (prevText != "N/A") {
arr[0] = document.getElementById("prevButtonText").innerHTML.charAt(0);
}
else {
arr[0] = 'C'
}
if (playText != "N/A") {
arr[1] = document.getElementById("playButtonText").innerHTML.charAt(0);
}
else {
arr[1] = 'V'
}
if (nextText != "N/A") {
arr[2] = document.getElementById("nextButtonText").innerHTML.charAt(0);
}
else {
arr[2] = 'B'
}
if (volDownButtonText != "N/A") {
arr[3] = document.getElementById("volDownButtonText").innerHTML.charAt(0);
}
else {
arr[3] = 'N'
}
if (volUpButtonText != "N/A") {
arr[4] = document.getElementById("volUpButtonText").innerHTML.charAt(0);
}
else {
arr[4] = 'M'
}
// check hero detector value!
let c = $('#detectionFlag:checked').val();
if(c == 'on') {
arr[5] = true;
heroDetectionOn = true;
} else {
arr[5] = false;
heroDetectionOn = false;
}
console.log("Setting buttons... ", arr[0], arr[1], arr[2], arr[3], arr[4], arr[5]);
ipcRenderer.send('SetButtons', arr);
}
function clearStorageButton() {
var answer = confirm("This is a secret button meant to clear some administrative settings. If you didn't mean to click it, press CANCEL. To clear administrative settings click ok. Warning, this may break stuff.");
if(answer){
var arr = ["C", "V", "B", "N", "M"];
console.log("Clearing storage......");
ipcRenderer.send('ClearStorageButton', arr);
}
else {
return;
}
}
ipcRenderer.on('NEXTSONG', (event, message) => {
console.log(message)
webview.executeJavaScript("document.getElementById('nextSongButton').click();")
})
ipcRenderer.on('PLAYSONG', (event, message) => {
console.log(message)
webview.executeJavaScript("document.getElementById('playPauseButton').click();")
})
ipcRenderer.on('PREVIOUSSONG', (event, message) => {
console.log(message)
webview.executeJavaScript("document.getElementById('prevSongButton').click();")
})
ipcRenderer.on('VOLDOWN', (event, message) => {
console.log(message)
webview.executeJavaScript("var x = $('#vol').slider(); val = $('#vol').data('slider').getValue(); x.slider('setValue', val - 10); changeVolume(val - 10)")
})
ipcRenderer.on('VOLUP', (event, message) => {
console.log(message)
webview.executeJavaScript("var x = $('#vol').slider(); val = $('#vol').data('slider').getValue(); x.slider('setValue', val + 10); changeVolume(val + 10)")
})
ipcRenderer.on('UPDATEBINDINGS', (event, message) => {
console.log("Changing bindings to... " + message)
json = JSON.parse(message)
document.getElementById("prevButtonText").innerHTML = json.PREVSONGKEY + " [click to change]"
document.getElementById("playButtonText").innerHTML = json.PLAYSONGKEY + " [click to change]"
document.getElementById("nextButtonText").innerHTML = json.NEXTSONGKEY + " [click to change]"
document.getElementById("volDownButtonText").innerHTML = json.VOLDOWNKEY + " [click to change]"
document.getElementById("volUpButtonText").innerHTML = json.VOLUPKEY + " [click to change]"
console.log("SETTING ", json.HERODETECTIONFLAG);
document.querySelector('#detectionFlag').checked = json.HERODETECTIONFLAG;
heroDetectionOn = json.HERODETECTIONFLAG;
})
webview.addEventListener('new-window', (e) => {
const protocol = require('url').parse(e.url).protocol
if (protocol === 'http:' || protocol === 'https:') {
open(e.url)
}
});
</script>
</html>